题目链接:http://codeforces.com/problemset/problem/459/A

题目意思:给出两个点的坐标你,问能否判断是一个正方形,能则输出剩下两点的坐标,不能就输出 -1。

这题更傻了,在考虑对角线的两点时,少考虑了一种情况:两个点分属不同象限:这时需要用到绝对值函数 abs !

最近集训不知道是不是搞傻左,反正CF的题目打了几场,结果都很惨,有一点点恐惧感,怕跌回以前不堪的rating。唉~~~继续努力吧!!!

 #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std; int main()
{
int x1, y1, x2, y2;
while (scanf("%d%d%d%d", &x1, &y1, &x2, &y2) != EOF)
{
// 两点平行,绝对有解
if (x1 == x2 && y1 != y2) // x 坐标相同
{
if (x1 + (y1-y2) >= - && x1 + (y1-y2) <= ) // 这是为了严谨起见,可能会超出给定范围
printf("%d %d %d %d\n", x1 + (y1-y2), y1, x2 + (y1-y2), y2);
else
printf("%d %d %d %d\n", x1 + (y2-y1), y1, x2 + (y2-y1), y2);
}
else if (y1 == y2 && x1 != x2) // y 坐标相同
{
if ((x1-x2) + y1 >= - && (x1-x2) + y1 <= )
printf("%d %d %d %d\n", x1, (x1-x2) + y1, x2, (x1-x2) + y2);
else
printf("%d %d %d %d\n", x1, (x2-x1) + y1, x2, (x2-x1) + y2);
}
// 对角线情况不一定有解
else if (abs(x1 - x2) == abs(y1 - y2)) // 对角线
{
printf("%d %d %d %d\n", x1, y2, x2, y1);
}
else
{
printf("-1\n");
}
}
return ;
}

codeforces 459 A. Pashmak and Garden 解题报告的更多相关文章

  1. codeforces 459 B.Pashmak and Flowers 解题报告

    题目链接:http://codeforces.com/problemset/problem/459/B 题目意思:有 n 朵 flowers,每朵flower有相应的 beauty,求出最大的beau ...

  2. codeforces 459C Pashmak and Buses 解题报告

    题目链接:http://codeforces.com/problemset/problem/459/C 题目意思:有 n 个 students,k 辆 buses.问是否能对 n 个students安 ...

  3. codeforces C1. The Great Julya Calendar 解题报告

    题目链接:http://codeforces.com/problemset/problem/331/C1 这是第一次参加codeforces比赛(ABBYY Cup 3.0 - Finals (onl ...

  4. codeforces B. Eugeny and Play List 解题报告

    题目链接:http://codeforces.com/problemset/problem/302/B 题目意思:给出两个整数n和m,接下来n行给出n首歌分别的奏唱时间和听的次数,紧跟着给出m个时刻, ...

  5. codeforces 433C. Ryouko's Memory Note 解题报告

    题目链接:http://codeforces.com/problemset/problem/433/C 题目意思:一本书有 n 页,每页的编号依次从 1 到 n 编排.如果从页 x 翻到页 y,那么| ...

  6. codeforces 459 E. Pashmak and Graph(dp)

    题目链接:http://codeforces.com/contest/459/problem/E 题意:给出m条边n个点每条边都有权值问如果两边能够相连的条件是边权值是严格递增的话,最长能接几条边. ...

  7. codeforces 459 D. Pashmak and Parmida's problem(思维+线段树)

    题目链接:http://codeforces.com/contest/459/problem/D 题意:给出数组a,定义f(l,r,x)为a[]的下标l到r之间,等于x的元素数.i和j符合f(1,i, ...

  8. codeforces 459 C. Pashmak and Buses(思维)

    题目链接:http://codeforces.com/problemset/problem/459/C 题意:有n个人,k辆车,d天要求没有两个人在d天都坐在一起.输出坐的方法. 题解:这题很有意思, ...

  9. codeforces 556B. Case of Fake Numbers 解题报告

    题目链接:http://codeforces.com/problemset/problem/556/B 题目意思:给出 n 个齿轮,每个齿轮有 n 个 teeth,逆时针排列,编号为0 ~ n-1.每 ...

随机推荐

  1. CKeditor如何实现图片上传功能

    http://makaiyuan.blog.51cto.com/5819595/1049521 如何在数据库中导入excel文件内的数据:http://jingyan.baidu.com/album/ ...

  2. kafka基础介绍

    kafka基础介绍 一.kafka介绍 1.1主要功能 根据官网的介绍,kafka是一个分布式流媒体的平台,它主要有三大功能: 1.11:It lets you publish and subscri ...

  3. Java中循环与选择语句

    public class Ifelse{ public static void main(String [] args){ int score=98; if(score>=90&& ...

  4. android Activity生命周期的例子

    package com.example.yanlei.yl2; import android.app.AlertDialog; import android.content.DialogInterfa ...

  5. Go -- 通过GOTRACEBACK生成程序崩溃后core文件的方法(gcore gdb)

    写一个错误的c程序   package dlsym import "testing" func Test_intercept(t *testing.T) { Intercept(& ...

  6. Spring boot 整合spring Data JPA+Spring Security+Thymeleaf框架(上)

    近期上班太忙所以耽搁了给大家分享实战springboot 框架的使用. 以下是spring boot 整合多个框架的使用. 首先是准备工作要做好. 第一  导入框架所需的包,我们用的事maven 进行 ...

  7. 天下文章一大抄 mysql远程连接

    使用GRANT命令创建远程连接mysql授权用户特定用户mysql -u root -ppassword   注意:p后面没有空格直接密码.mysql>grant all privileges ...

  8. Solidworks如何绘制装饰螺纹线

    1 插入-注解,装饰螺纹线   2 绘制装饰螺纹线,选择螺纹的边线,标准选择ISO,下面可以选择的范围就确定了(M6的孔,只能选择M8的螺纹或者M10的螺纹),画好之后在3D图中并没有明确的螺纹样式 ...

  9. XUtils BitmapUtils 改造以加入drawable支持

    === XUtilsBitmapUtils 改造以加入drawable支持 === # XUtils 简单介绍 XUtils 是一套少有的早期国产安卓框架, 其源于AFinal, 文件夹结构也与之相似 ...

  10. unix && linux

    区别和联系 Linux和UNIX的最大的区别是,前者是开发源代码的自由软件,而后者是对源代码实行知识产权保护的传统商业软件.这应该是他们最大的不同,这种不同体现在用户对前者有很高的自主权,而对后者却只 ...