A. Pashmak and Garden
来源:互联网 发布:office for mac激活 编辑:程序博客网 时间:2024/05/18 05:32
Pashmak has fallen in love with an attractive girl called Parmida since one year ago...
Today, Pashmak set up a meeting with his partner in a romantic garden. Unfortunately, Pashmak has forgotten where the garden is. But he remembers that the garden looks like a square with sides parallel to the coordinate axes. He also remembers that there is exactly one tree on each vertex of the square. Now, Pashmak knows the position of only two of the trees. Help him to find the position of two remaining ones.
The first line contains four space-separated x1, y1, x2, y2 ( - 100 ≤ x1, y1, x2, y2 ≤ 100) integers, where x1 and y1 are coordinates of the first tree and x2 and y2 are coordinates of the second tree. It's guaranteed that the given points are distinct.
If there is no solution to the problem, print -1. Otherwise print four space-separated integers x3, y3, x4, y4 that correspond to the coordinates of the two other trees. If there are several solutions you can output any of them.
Note that x3, y3, x4, y4 must be in the range ( - 1000 ≤ x3, y3, x4, y4 ≤ 1000).
0 0 0 1
1 0 1 1
0 0 1 1
0 1 1 0
0 0 1 2
-1
解题说明:此题是一道几何题,给定两个点,问能否再添加两个点构成正方形,简单判断即可。
#include<iostream>#include<cstdio>#include<cmath>#include<algorithm>#include<cstdlib>#include<cstring>using namespace std;int main(){int a, b, c, d;scanf("%d%d%d%d", &a, &b, &c, &d);if (a == c){printf("%d %d %d %d\n", a - abs(b - d), b, c - abs(b - d), d);}else if (b == d){printf("%d %d %d %d\n", a, b - abs(a - c), c, d - abs(a - c));}else if (abs(a - c) == abs(b - d)){printf("%d %d %d %d\n", a, d, c, b);}else{printf("-1\n");}return 0;}
- A. Pashmak and Garden
- A. Pashmak and Garden
- 【CODEFORCES】 A. Pashmak and Garden
- Codeforces 459A Pashmak and Garden(水题)
- codeforces-#459A Pashmak and Garden
- codeforces 459A. Pashmak and Garden
- CF 261A. Pashmak and Garden
- CF 261A. Pashmak and Garden
- Codeforces-459A-Pashmak and Garden
- cf459A Pashmak and Garden
- Pashmak and Garden
- Pashmak and Garden
- Codeforces Round #261 (Div. 2) A. Pashmak and Garden (水题)
- Codeforces Round #261 (Div. 2) A. Pashmak and Garden
- Codeforces #261 (Div. 2) A. Pashmak and Garden(水题)
- Codeforces Round #261 (Div. 2) A. Pashmak and Garden【水】
- Codeforces Round #261 (Div. 2) A. Pashmak and Garden
- Codeforces Round #261 (Div. 2)A. Pashmak and Garden
- 关于八码数问题有解与无解的证明
- 两种矩阵转置的代码
- 雄迈 定制开发 图像质量更好
- Discuz! 全局变量 $_G
- 学习笔记--最小生成树之kruskal算法
- A. Pashmak and Garden
- #pragma 使用记录
- linux 64 支付宝插件问题
- 计算机中的负数是如何表示的?
- 计数排序
- Java多线程之队列Queue
- Insertion Sort List
- UNIX Domain Sockets
- HDU 3790-最短路径问题(双权最短路)