cf459A Pashmak and Garden
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
大家好我是紫名选手T T第二次akdiv2了
第一题神模拟……有一个边和xy轴平行的正方形,给两个点,要输出另两个点,不存在就输出-1
然后就是各种判断啦T T
x1==x2的时候分一类,y1==y2的时候分一类,否则是对角线的位置分一类,然后判一下-1就好了
直接把x1==x2和y1==y2的输出一大堆拷过去再改的,然后忘记交换x和y了QAQ
#include<iostream>
#include<cstdio>
#define LL long long
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline int abs(int a)
{return a<?-a:a;}
int x1,x2,y1,y2;
int main()
{
x1=read();y1=read();x2=read();y2=read();
if (x1==x2)
{
printf("%d %d %d %d",abs(y2-y1)+x1,y1,abs(y2-y1)+x1,y2);
}else
if (y1==y2)
{
printf("%d %d %d %d",x1,abs(x2-x1)+y1,x2,abs(x2-x1)+y1);
}else
{
if (abs(x1-x2)!=abs(y1-y2)){printf("-1");return ;}
printf("%d %d %d %d",x1,y2,x2,y1);
}
}
cf459A
cf459A Pashmak and Garden的更多相关文章
- CF459A Pashmak and Garden (水
Pashmak and Garden Codeforces Round #261 (Div. 2) A. Pashmak and Garden time limit per test 1 second ...
- 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 ...
- Codeforce 459A - Pashmak and Garden (已知两点求另外两点构成正方形)
Pashmak has fallen in love with an attractive girl called Parmida since one year ago... Today, Pashm ...
- CodeForces 459A Pashmak and Garden(水~几何-给两点求两点组成正方形)
题目链接:http://codeforces.com/problemset/problem/459/A 题目大意: 给出两个点(在坐标轴中),求另外两个点从而构成一个正方形,该正方形与坐标轴平行. 如 ...
- codeforces 459 A. Pashmak and Garden 解题报告
题目链接:http://codeforces.com/problemset/problem/459/A 题目意思:给出两个点的坐标你,问能否判断是一个正方形,能则输出剩下两点的坐标,不能就输出 -1. ...
- CF 459A(Pashmak and Garden-正方形给出2点求2点)
A. Pashmak and Garden time limit per test 1 second memory limit per test 256 megabytes input standar ...
- New Training Table
2014_8_15 CodeForces 261 DIV2 A. Pashmak and Garden 简单题 B. Pashmak and Flowers 简单题 C. P ...
- CF 459A && 459B && 459C && 459D && 459E
http://codeforces.com/contest/459 A题 Pashmak and Garden 化简化简水题,都告诉平行坐标轴了,数据还出了对角线,后面两个点坐标给的范围也不错 #in ...
- Codeforces Round #261 (Div. 2)[ABCDE]
Codeforces Round #261 (Div. 2)[ABCDE] ACM 题目地址:Codeforces Round #261 (Div. 2) A - Pashmak and Garden ...
随机推荐
- HttpApplication中的异步线程
一.Asp.net中的线程池设置 在Asp.net的服务处理中,每当服务器收到一个请求,HttpRuntime将从HttpApplication池中获取一个HttpApplication对象处理此请求 ...
- css案例学习之table tr th td ul li实现日历
效果 代码 <html> <head> <title>Calendar</title> <style> <!-- .month { b ...
- LeeCode-Rotate Array
Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array ...
- javadoc 生成帮助文档时,注意以下几点
参考:http://www.w3school.com.cn/tags/tag_pre.asp javadoc 生成帮助文档时,注意以下几点: 1.函数功能描述的结尾一定要有句号,英文句号或中文句号均可 ...
- 兼容各个浏览器的H.264播放: H.264+HTML5+FLOWPLAYER+WOWZA+RMTP
一.方案确定 计划做视频播放,要求可以播放H264编码的mp4文件,各个浏览器,各种终端都能播放. 首先查找可行性方案, http://www.cnblogs.com/sink_cup/archive ...
- java学习笔记day01
1.Java JDK:简称为java开发工具集 2.下载JDK后安装,可以下载绿色版本,即不用安装,直接将其放在磁盘根目录 如:C:\Java\jdk1.6.0_10 3.在任意磁盘路径下都可以编译 ...
- vmware tools 安装
转到虚拟机 > 安装 VMware Tools(或 VM > 安装 VMware Tools).注意:如果您运行的是轻量版的 Fusion.不带 VMware Tools 的 Workst ...
- java中String的用法
String的用法很活跃,也用到的很多.可以根据自己的需要查询API.这里只有concat和substring,indexof的用法 class TestString { public static ...
- c++中各种数据类型所占字节
求各种数据类型所占用的字节数可调用sizeof函数,求各种数据类型的最大值可以调用limits标准库中的numeric_limits<T>::max(),numeric_limits< ...
- 对WEB标准以及W3C的理解与认识 - 提高网页加载速度
在写代码的时候应该注意: 1.标签闭合 2.标签小写 3.不能随意嵌套 提高被搜索引擎搜到几率: mate中的name变量[其中keywords和description尤其重要] Meta name= ...