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.

Input

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.

Output

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).

Examples
input
  1. 0 0 0 1
output
  1. 1 0 1 1
input
  1. 0 0 1 1
output
  1. 0 1 1 0
input
  1. 0 0 1 2
output
  1. -1

题解:分情况讨论即可:同行.同列.对角线.无解

  1. #include <iostream>
  2. #include <algorithm>
  3. #include <cstring>
  4. #include <cstdio>
  5. #include <vector>
  6. #include <cstdlib>
  7. #include <iomanip>
  8. #include <cmath>
  9. #include <ctime>
  10. #include <map>
  11. #include <set>
  12. using namespace std;
  13. #define lowbit(x) (x&(-x))
  14. #define max(x,y) (x>y?x:y)
  15. #define min(x,y) (x<y?x:y)
  16. #define MAX 100000000000000000
  17. #define MOD 1000000007
  18. #define pi acos(-1.0)
  19. #define ei exp(1)
  20. #define PI 3.141592653589793238462
  21. #define INF 0x3f3f3f3f3f
  22. #define mem(a) (memset(a,0,sizeof(a)))
  23. typedef long long ll;
  24. const int N=;
  25. const int mod=1e9+;
  26. int main()
  27. {
  28. int x1_,x2_,y1_,y2_;
  29. cin>>x1_>>y1_>>x2_>>y2_;
  30. if (x1_==x2_){
  31. int d=abs(y1_-y2_);
  32. printf("%d %d %d %d\n",x1_+d,y1_,x2_+d,y2_);
  33. }
  34. else if (y1_==y2_){
  35. int d=abs(x1_-x2_);
  36. printf("%d %d %d %d\n",x1_,y1_+d,x2_,y2_+d);
  37. }
  38. else if(abs(x1_-x2_)==abs(y1_-y2_)){
  39. printf("%d %d %d %d\n",x2_,y1_,x1_,y2_);
  40. }
  41. else cout<<"-1\n";
  42. return ;
  43. }

Codeforce 459A - Pashmak and Garden (已知两点求另外两点构成正方形)的更多相关文章

  1. CodeForces 459A Pashmak and Garden(水~几何-给两点求两点组成正方形)

    题目链接:http://codeforces.com/problemset/problem/459/A 题目大意: 给出两个点(在坐标轴中),求另外两个点从而构成一个正方形,该正方形与坐标轴平行. 如 ...

  2. poj 2002(好题 链式hash+已知正方形两点求另外两点)

    Squares Time Limit: 3500MS   Memory Limit: 65536K Total Submissions: 18493   Accepted: 7124 Descript ...

  3. Codeforces Round #261 (Div. 2)459A. Pashmak and Garden(数学题)

    题目链接:http://codeforces.com/problemset/problem/459/A A. Pashmak and Garden time limit per test 1 seco ...

  4. 已知直线上的两点 A(x1, y1), B(x2, y2) 和另外一点 C(x0, y0),求C点到直线的距离。

    数学知识太差,一点点积累,高手勿喷. 1. 先求出AB向量 a = ( x2-x1, y2-y1 ) 2. 求AB向量的单位方向向量 b = √((x2-x1)^2 + (y2-y1)^2)) a1 ...

  5. 已知 $AB$, 求 $BA$

    设 $A,B$ 分别是 $3\times 2$ 和 $2\times 3$ 实矩阵. 若 $\dps{AB=\sex{\ba{ccc}  8&0&-4\\  -\frac{3}{2}& ...

  6. C语言初学 给已知公式求圆周率

    公式: 圆周率=1-1/3+1/5-1/7+......+1/(4n-3)-1/(4n-1) #include<stdio.h> #include<math.h> main() ...

  7. 使用python已知平均数求随机数

    问题描述:产生40个数,范围是363-429之间,平均值为402 思路: 1 产生一个随机数 2 使用平均数减去随机数求出第二个数,生成20组 3 将排序打乱 # -*- coding: cp936 ...

  8. 转 已知两点坐标和半径求圆心坐标程序C++

      数学思想:利用圆方程和直线方程 已知两点坐标和半径求圆心坐标程序 #include <iostream> #include <fstream> #include <c ...

  9. 已知空间两点组成的直线求线上某点的Z值

    已知空间两点组成的直线求线上某点的Z值,为什么会有这种看起来比较奇怪的求值需求呢?因为真正三维空间的几何计算是比较麻烦的,很多时候需要投影到二维,再反推到三维空间上去. 复习下空间直线方程:已知空间上 ...

随机推荐

  1. Deepin下将Caps映射为Control_L键

    xmodmap -e 'clear Lock' -e 'keycode 0x42 = Control_L'

  2. JavaScript——基础知识,开始我们的js编程之旅吧!

    JavaScript基础第01天 1. 编程语言 编程语言: 可以通过类似于人类语言的"语言"来控制计算机,让计算机为我们做事情,这样的语言就叫做编程语言(Programming ...

  3. UML之一、为什么需要UML?

    think in uml学习 面向对象和面向过程是两种不同描述世界的方法. 面向过程:世界视为过程,世界由一个个相互关联的小程序构建来的,是精密的. 但是构成一个系统的因素太多,要把所有可能的因素都考 ...

  4. RabbitMQ工作模式

    ------------恢复内容开始------------ RabbitMQ基本概念: Producer:生产者(消息的提供者) Consumer:消费者(消息的使用者) Message:消息(程序 ...

  5. Java基础之二、类的知识

    类定义---方法及其处理的数据对象的集合结构 将现实的对象(物体)和概念映射到程序中的对象(变量)中 1:使用new运算符创建的类类型的主体称为实例,创建实例的操作称为实例化, new Account ...

  6. [PHP] 使用PHP在mongodb中进行嵌套查询

    作为文档数据库,数据库中存储的数据是类似json的结构,比如{“modelInfo”:{"status":1,audited:"1"}},想要查询status是 ...

  7. 流程图GGEditor 之 自定义节点相关属性

    自定义节点 注册 -- registerNode 我们通过以下接口往 G6 全局注册节点: // 注册节点 G6.registerNode(name, { // 绘制 draw(item) {   r ...

  8. 动态加载js文件是异步的

    动态加载js文件是异步的. 今天调试一个错误,一个js方法各种调不到. 原因是因为所调方法的js文件是动态加载进来的. <script type="text/javascript&qu ...

  9. Docker Compose搭建ELK

    Elasticsearch默认使用mmapfs目录来存储索引.操作系统默认的mmap计数太低可能导致内存不足,我们可以使用下面这条命令来增加内存: sysctl -w vm.max_map_count ...

  10. 吴裕雄--天生自然 python开发学习笔记:Git安装配置流程