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
题意:
给出 x1,x2,y1,y2,问能不能构成正方形,能则输出另外两点。不能则输出 -1。
思路:
模拟。分情况讨论清楚就行。
AC:
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; int main() { int x1, y1, x2, y2; scanf("%d%d%d%d", &x1, &y1, &x2, &y2); int lenx = abs(x1 - x2); int leny = abs(y1 - y2); if (lenx && leny && lenx != leny) printf("-1\n"); else if (!lenx) printf("%d %d %d %d\n", (x1 + leny), y1, (x1 + leny), y2); else if (!leny) printf("%d %d %d %d\n", x1, y1 + lenx, x2, y1 + lenx); else printf("%d %d %d %d\n", x2, y1, x1, y2); return 0; }
相关推荐
UL 62841-3-7:2021 Electric Motor-Operated Hand-Held Tools, Transportable Tools and Lawn and Garden Machinery - Safety - Part 3-7:Particular Requirements for Transportable Wall Saws - 完整英文版(41...
arlier this month, Michelle Obama and twenty-three schoolchildren helped prepare the ground for an organic vegetable garden on the South Lawn of the White House.
Jelly Garden Match 3
Rosegarden
BS EN ISO 5395-1-2013.Garden equipment — Safetyrequirements for combustionengine-powered lawnmowers ...Committee AGE/20, Powered lawn and garden equipment. A list of organizations represented
公司蛋疼的网络,非常封闭,只能上几个为数不多的技术网站,我只好Down下来传到CSDN 再去公司下。 JS garden 非常值得学习的总结
by the loading and balancing system of Huajun software garden,only for the stat. of servers, meaningless to the customers. ================================================================ QA2IjrnHt...
默认积分是1,不能为0,所以在这里说下地址:下载的文件地址在这里:https://github.com/billfienberg/grid-garden
CSS Zen Garden
python库。 资源全名:kivy_garden.zbarcam-2019.1020.tar.gz
想学习CSS布局吗,就来我们里找很好的素材,包你看一遍,想看第二遍,真的爱不释手,不信你下一下想学习CSS布局吗,就来我们里找很好的素材,包你看一遍,想看第二遍,真的爱不释手,不信你下一下
讲述了位同步的经典算法,很不错的代码,里面很详细的编程注释,适合初学者的学习和参考
Garden是一款开发人员工具,可自动完成工作流程,使Kubernetes应用程序的开发和测试变得前所未有的快捷
资源来自pypi官网。 资源全名:kivy_garden.mapview-1.0.5.tar.gz
锡基特花园 Scikit-Garden或skgarden(发音为skarden)是Scikit-Learn兼容决策树和森林的花园。MondrianTree不同深度的权重波士顿数据集上的有序预测间隔。安装Scikit-Garden依赖于NumPy,SciPy,Scikit-Learn和...
obsidian数字花园参照模板 obsidian使用说明书
JavaScript经典问题,很好的学习js,深入js
A garden of poems
园林景观设计素材,找网页素材找到的,可以兼用于休闲消遣。英文版