CF 459A(Pashmak and Garden-正方形给出2点求2点)
1 second
256 megabytes
standard input
standard output
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
分为同行。同列,对角线,无解4种情况
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<iostream>
#include<cmath>
#include<cctype>
#include<ctime>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Lson (x<<1)
#define Rson ((x<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,127,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define INF (2139062143)
#define F (100000007)
long long mul(long long a,long long b){return (a*b)%F;}
long long add(long long a,long long b){return (a+b)%F;}
long long sub(long long a,long long b){return (a-b+(a-b)/F*F+F)%F;}
typedef long long ll;
int main()
{
// freopen("a.in","r",stdin);
// freopen("a.out","w",stdout);
int x1_,x2_,y1_,y2_;
cin>>x1_>>y1_>>x2_>>y2_;
if (x1_==x2_)
{
int d=abs(y1_-y2_);
printf("%d %d %d %d\n",x1_+d,y1_,x2_+d,y2_);
}
else
if (y1_==y2_)
{
int d=abs(x1_-x2_);
printf("%d %d %d %d\n",x1_,y1_+d,x2_,y2_+d);
}
else
{
if (abs(x1_-x2_)==abs(y1_-y2_))
{
printf("%d %d %d %d\n",x2_,y1_,x1_,y2_);
}
else cout<<"-1\n";
}
return 0;
}
CF 459A(Pashmak and Garden-正方形给出2点求2点)的更多相关文章
- 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 ...
- CodeForces 459A Pashmak and Garden(水~几何-给两点求两点组成正方形)
题目链接:http://codeforces.com/problemset/problem/459/A 题目大意: 给出两个点(在坐标轴中),求另外两个点从而构成一个正方形,该正方形与坐标轴平行. 如 ...
- Codeforce 459A - Pashmak and Garden (已知两点求另外两点构成正方形)
Pashmak has fallen in love with an attractive girl called Parmida since one year ago... Today, Pashm ...
- CF459A Pashmak and Garden (水
Pashmak and Garden Codeforces Round #261 (Div. 2) A. Pashmak and Garden time limit per test 1 second ...
- cf459A Pashmak and Garden
A. Pashmak and Garden time limit per test 1 second memory limit per test 256 megabytes input standar ...
- CF 459A && 459B && 459C && 459D && 459E
http://codeforces.com/contest/459 A题 Pashmak and Garden 化简化简水题,都告诉平行坐标轴了,数据还出了对角线,后面两个点坐标给的范围也不错 #in ...
- CodeForces 702B Powers of Two【二分/lower_bound找多少个数/给出一个数组 求出ai + aj等于2的幂的数对个数】
B. Powers of Two You are given n integers a1, a2, ..., an. Find the number of pairs of indexes i, ...
- codeforces 459 A. Pashmak and Garden 解题报告
题目链接:http://codeforces.com/problemset/problem/459/A 题目意思:给出两个点的坐标你,问能否判断是一个正方形,能则输出剩下两点的坐标,不能就输出 -1. ...
- cf 459c Pashmak and Buses
E - Pashmak and Buses Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I ...
随机推荐
- 我使用过的Linux命令
我使用过的Linux命令之tee - 重定向输出到多个文件 用途说明 在执行Linux命令时,我们可以把输出重定向到文件中,比如 ls >a.txt,这时我们就不能看到输出了,如果我们既想把输出 ...
- node-webkit 使用nodejs第三方C/C++插件
node-webkit 在window环境下使用C/C++插件,需要使用nw-gyp先编译.本文以编译node-expat演示操作过程: 1.安装nodejs: 最好将nodejs的执行路径添加进系统 ...
- 服务启动项 Start类型详解
注册表的服务启动项 Start类型详解 HKLM\SYSTEM\CurrentControlSet\services\ 下的服务项.不论有没有在services.msc服务管理控制台中显示,在注册表中 ...
- 产品在焊接时出现异常,尤其是尺寸较大的QFP芯片,焊接后出现虚焊、冷焊、假焊等问题?
1 不良描述 客户采用我们提供的SMT设备后,部分产品在焊接时出现异常,尤其是尺寸较大的QFP芯片,焊接后出现虚焊.冷焊.假焊等不良.应客户要求对这一批不良产品以及生产条件进行分析,以便找到改善的依据 ...
- Windows Azure 社区新闻综述(#72 版)
欢迎查看最新版本的每周综述,其中包含有关云计算和 Windows Azure的社区推动新闻.内容和对话. 以下是过去一周基于您的反馈汇集在一起的内容: 文章 · 在 Windows Azure 移 ...
- ZOJ 38727(贪心)
这道题真心坑.越想越远 想的飞起来了. 最后纠结起后缀表达式的定义来了. 题意: 就是给你一个串 , 让你用最少改动次数来实它变成一个合法的后缀表达式, 改动方式有两种, 一种是直接加入数字或者 ...
- Git怎样同一时候删除多个仓下的同一个分支
每次下载完代码我们都会在本地通过repo start my_local --all建立分支,这样我们下载的代码在每一个仓下都有一个名叫my_local的分支,有些时候我们因为须要还会建立其它分支,当我 ...
- AngularJs 简单入门
1.AngularJs 是什么以及应用程序组成的三部分 AngularJS是一个开发动态Web应用的框架.它让你可以使用HTML作为模板语言并且可以通过扩展的HTML语法来使应用组件更加清晰和简洁.它 ...
- Webform中linq to sql多条件查询(小练习)
多条件查询:逐条判断,从第一个条件开始判断,如果满足,取出放入集合,再从集合中查询第二个条件... aspx代码: <body> <form id="form1" ...
- SQL Server和MySql获取当前数据库每个表的列数
Sql server:(连接数据库后,点击当前数据库再新建查询) select count(c.name),o.name from syscolumns c left join sysobjects ...