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 ...
随机推荐
- 浅谈Hash函数
什么是hash函数: hash函数也可以翻译成“散列”函数,一般就使用音译“哈希”函数,简单的说哈希函数是对任意长度的输入进行的压缩映射,所谓的压缩映射顾名思义,输出通常来说要比输入短,并且得到的输出 ...
- Hadoop学习之Mapreduce执行过程详解
一.MapReduce执行过程 MapReduce运行时,首先通过Map读取HDFS中的数据,然后经过拆分,将每个文件中的每行数据分拆成键值对,最后输出作为Reduce的输入,大体执行流程如下图所示: ...
- php学习笔记(1)
1.引用文件的方法有两种:require 及 include require 的使用方法如 require("MyRequireFile.php"); .这个函数通常放在 PHP ...
- 四轴飞行器1.6 emwin与ucgui的移植,汉字外挂字库移植和DEMO效果对比
飞控的遥控器打算自己做,这样全局都能掌握,可以通过遥控器对飞控的参数和飞行模式进行修改,而买遥控器是做不到这样的哈..以后做图传的时候,屏幕还可以实时现实摄像头拍回来的画面,挺好的哈.. 做遥控我们选 ...
- 记录.net 中的常见术语
--Entity Framework和NHibernate --EF和NH都是一种ORM技术.就是对象关系模型映射. --NHibernate和Entity Framework 4.0优劣势争论 -- ...
- Delphi2010新发现-类的构造和析构函数功能
Delphi2010发布了. 虽然凭着对Delphi的热爱第一时间就安装了,但是现在可能是年纪大了,对新事物缺乏兴趣了.一直都没有仔细研究. 今天有点时间试了一下新功能. 本来C#和Delphi.NE ...
- 转:C++中多态是怎样实现的?
多态是一种不同的对象以单独的方式作用于相同消息的能力,这个概念是从自然语言中引进的.例如,动词“关闭”应用到不同的事务上其意思是不同的.关门,关闭银行账号或关闭一个程序的窗口都是不同的行为:其实际的意 ...
- Hibernate 配置详解(12) 其实我也不想用这么土的名字
hibernate.hbm2ddl.import_files 这个配置用于在hibernate根据映射文件执行DDL之前,如果我们自己设置了要事先运行的SQL文件,hibernate就会先执行这些SQ ...
- Cocos2d-x lua游戏开发之安装Lua到mac系统
注意:mac ox .lua version :5.15 下载lua官网的lua, 注意:最好是5.15下面.5.2的lua不支持table的getn()方法,这让我情何以堪.(获取table长度.相 ...
- 手把手教你在openshift上搭建wordpress博客(二)
相同公布于:http://www.longgaming.com/archives/128 推荐前往阅读 这一篇文章主要介绍一些经常使用插件的使用和配置. 下面是我个人安装的一些插件.大家能够依据须要自 ...