题目链接: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. oracle怎么查看表空间里有哪些表

    select TABLE_NAME,TABLESPACE_NAME from dba_tables where TABLESPACE_NAME='表空间名'; 注意:表空间名要大写

  2. 使用<sstream> 替代<stdio.h>

    c++ 字符串流 sstream(常用于格式转换)   使用stringstream对象简化类型转换C++标准库中的<sstream>提供了比ANSI C的<stdio.h>更 ...

  3. 选取第K大数的快速选择算法和注意事项

    快速选择算法,是一种能在大致O(N)的时间内选取数组中第k大或者k小的算法.其基本思路与快速排序算法类似,也是分治的思想. 其实这个算法是个基础算法,但是不常用,所以今天编的时候错了POJ2388,才 ...

  4. HUNAN 11569 Just Another Knapsack Problem(AC自动机+dp)

    http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11569&courseid=0 给出目标串,每个子串和 ...

  5. Linux配置防火墙添加端口(Ubuntu/Debian无法使用此方法)

    注意:Ubuntu/Debian无法使用此方法 1.打开iptables vi /etc/sysconfig/iptables 2.添加防火墙规则 规则参考:http://www.cnblogs.co ...

  6. ORACLE 内部原理

    http://www.ohsdba.cn/index.php?m=Article&a=index&id=46 内部原理 2016-05-04• 如何使用BBED 2016-04-16• ...

  7. js中有包装类,java中也有包装类

    new Number() vs Number() What is the difference between new Number() and Number()? I get that new Nu ...

  8. 转:linux下ip修改与域名解析查看等

    转自: http://www.justwinit.cn/post/7038/ IP:     ifconfiggateway:172.16.0.254 [root@localhost ~]# nets ...

  9. Solidworks修改零件文件名之后工程图找不到零件怎么办

    如下图所示,如果我直接把"压紧柱 V1.0"改名为"压紧柱",则打开工程图之后图纸都没了.   即便你用打开零件的方式找到了这个零件,工程图还是老样子   所以 ...

  10. pomelo加入定时任务

    需求:在arenaserver下添加一个rank定时任务,每一分钟对对玩家进行一次排行. 首先在game-server/app/servers/arena文件夹下添加cron文件夹. 在game-se ...