zoukankan      html  css  js  c++  java
  • 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.

    Input

    The first line contains four space-separated x1, y1, x2, y( - 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 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).

    Examples
    input
    0 0 0 1
    output
    1 0 1 1
    input
    0 0 1 1
    output
    0 1 1 0
    input
    0 0 1 2
    output
    -1
    题意:给出两个坐标,求另外两个坐标能不能构成正方形,不行输出-1
    解法:额,自己想怎么构造就怎么构造
     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 int main()
     4 {
     5     int x1,y1,x2,y2;
     6     cin>>x1>>y1>>x2>>y2;
     7     if(x1!=x2&&y1!=y2)
     8     {
     9         if(abs(x1-x2)!=abs(y1-y2))
    10         {
    11             cout<<"-1";
    12         }
    13         else
    14         {
    15             cout<<x1<<" "<<y2<<" "<<x2<<" "<<y1<<endl;
    16         }
    17     }
    18     else
    19     {
    20         if(x1==x2)
    21         {
    22             cout<<x1+abs(y1-y2)<<" "<<y1<<" "<<x2+abs(y1-y2)<<" "<<y2<<endl;
    23         }
    24         else
    25         {
    26             cout<<x1<<" "<<y1+abs(x1-x2)<<" "<<x2<<" "<<y2+abs(x1-x2)<<endl;
    27         }
    28     }
    29     return 0;
    30 }
  • 相关阅读:
    day11_获取前一条用例的结果(用参数化实现)
    day11_获取前一条用例的结果
    codeforce 1433F
    codeforces 1428 D. Bouncing Boomerangs (贪心)
    codeforces 761C
    codeforces 839C
    codeforces 859C
    codeforces 858C Did you mean... (贪心)
    codeforces 855B
    st表
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/6581964.html
Copyright © 2011-2022 走看看