Codeforces Round #261 (Div. 2) A
Description
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 integersx3, 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
题意:给出两个坐标,求另外两个坐标能不能构成正方形,不行输出-1
解法:额,自己想怎么构造就怎么构造
#include<bits/stdc++.h>
using namespace std;
int main()
{
int x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
if(x1!=x2&&y1!=y2)
{
if(abs(x1-x2)!=abs(y1-y2))
{
cout<<"-1";
}
else
{
cout<<x1<<" "<<y2<<" "<<x2<<" "<<y1<<endl;
}
}
else
{
if(x1==x2)
{
cout<<x1+abs(y1-y2)<<" "<<y1<<" "<<x2+abs(y1-y2)<<" "<<y2<<endl;
}
else
{
cout<<x1<<" "<<y1+abs(x1-x2)<<" "<<x2<<" "<<y2+abs(x1-x2)<<endl;
}
}
return ;
}
Codeforces Round #261 (Div. 2) A的更多相关文章
- Codeforces Round #261 (Div. 2)[ABCDE]
Codeforces Round #261 (Div. 2)[ABCDE] ACM 题目地址:Codeforces Round #261 (Div. 2) A - Pashmak and Garden ...
- Codeforces Round #261 (Div. 2) B
链接:http://codeforces.com/contest/459/problem/B B. Pashmak and Flowers time limit per test 1 second m ...
- Codeforces Round #261 (Div. 2) E. Pashmak and Graph DP
http://codeforces.com/contest/459/problem/E 不明确的是我的代码为啥AC不了,我的是记录we[i]以i为结尾的点的最大权值得边,然后wa在第35 36组数据 ...
- Codeforces Round #261 (Div. 2)459D. Pashmak and Parmida's problem(求逆序数对)
题目链接:http://codeforces.com/contest/459/problem/D D. Pashmak and Parmida's problem time limit per tes ...
- Codeforces Round #261 (Div. 2) - E (459E)
题目连接:http://codeforces.com/contest/459/problem/E 题目大意:给定一张有向图,无自环无重边,每条边有一个边权,求最长严格上升路径长度.(1≤n,m≤3 * ...
- Codeforces Round #261 (Div. 2) B. Pashmak and Flowers 水题
题目链接:http://codeforces.com/problemset/problem/459/B 题意: 给出n支花,每支花都有一个漂亮值.挑选最大和最小漂亮值得两支花,问他们的差值为多少,并且 ...
- 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 Round 261 Div.2 E Pashmak and Graph --DAG上的DP
题意:n个点,m条边,每条边有一个权值,找一条边数最多的边权严格递增的路径,输出路径长度. 解法:先将边权从小到大排序,然后从大到小遍历,dp[u]表示从u出发能够构成的严格递增路径的最大长度. dp ...
- Codeforces Round 261 Div.2 D Pashmak and Parmida's problem --树状数组
题意:给出数组A,定义f(l,r,x)为A[]的下标l到r之间,等于x的元素数.i和j符合f(1,i,a[i])>f(j,n,a[j]),求有多少对这样的(i,j). 解法:分别从左到右,由右到 ...
- Codeforces Round #261 (Div. 2)
第一场难得DIV2简单+AK人数多: E:给出一张图,求最多的边数,满足:在这个边的集合中后面的边的权值大于前面的边; 思路:我们将图按权值排列,以为只可能边权值小的跟新权值大的所以对于一条边我们只跟 ...
随机推荐
- 图像处理之基础---ffmpeg 中的图像缩放
http://blog.csdn.net/bweaglegao/article/details/8540860 http://www.cnblogs.com/acloud/archive/2011/1 ...
- Kafka知识点汇总
整体结构 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZXJpY19zdW5haA==/font/5a6L5L2T/fontsize/400/fill/I ...
- Boost下载安装编译配置使用指南(含Windows和Linux) .
理论上,本文适用于boost的各个版本,尤其是最新版本1.39.0:适用于各种C++编译器,如VC6.0(部分库不支持),VS2003,VS2005,VS2008,gcc,C++ Builder等.先 ...
- app上架的问题
1..p12证书文件(钥匙串导出)开发证书和描述文件的 2.app打包好重Xcode上传到iTunes中的时候最好做校验: 3.程序跑真机出现的问题 解决方法:debug 模式改成release模式 ...
- Codeforces Round #254 (Div. 2):B. DZY Loves Chemistry
B. DZY Loves Chemistry time limit per test 1 second memory limit per test 256 megabytes input standa ...
- NSString类的方法实现
创建一个新字符串并将其设置为 path 指定的文件的内容,使用字符编码enc,在error上返回错误 + (id)stringWithContentsOfURL:(NSURL *)url encodi ...
- Hadoop MapReduce基本原理
一.什么是: MapReduce是一种编程模型,用于大规模数据集(大于1TB)的并行运算.概念"Map(映射)"和"Reduce(归约)",是它们的主要思想,都 ...
- delphi 八字排盘源码(post数据以后,又分析数据)
procedure TForm1.Button14Click(Sender: TObject);var ls: TStringList; lstr: string; lss: TMemorySt ...
- vue中如何实现后台管理系统的权限控制
vuejs单页应用的权限管理实践 一.前言 在广告机项目中,角色的权限管理是卡了挺久的一个难点.首先我们确定的权限控制分为两大部分,其中根据粒的大小分的更细: 接口访问的权限控制 页面的权限控制 菜单 ...
- Opencv实现两幅图像融合
实现两幅图像线性(不同系数下)的融合涉及到Opencv中两个关键的方法,addWeighted()和createTrackbar() addWeighted方法: 函数原型: void addWeig ...