zoukankan      html  css  js  c++  java
  • Codeforce 459A

    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 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).

    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 #include <iostream>
     2 #include <algorithm>
     3 #include <cstring>
     4 #include <cstdio>
     5 #include <vector>
     6 #include <cstdlib>
     7 #include <iomanip>
     8 #include <cmath>
     9 #include <ctime>
    10 #include <map>
    11 #include <set>
    12 using namespace std;
    13 #define lowbit(x) (x&(-x))
    14 #define max(x,y) (x>y?x:y)
    15 #define min(x,y) (x<y?x:y)
    16 #define MAX 100000000000000000
    17 #define MOD 1000000007
    18 #define pi acos(-1.0)
    19 #define ei exp(1)
    20 #define PI 3.141592653589793238462
    21 #define INF 0x3f3f3f3f3f
    22 #define mem(a) (memset(a,0,sizeof(a)))
    23 typedef long long ll;
    24 const int N=205;
    25 const int mod=1e9+7;
    26 int main()
    27 {
    28     int x1_,x2_,y1_,y2_;
    29     cin>>x1_>>y1_>>x2_>>y2_;
    30     if (x1_==x2_){
    31         int d=abs(y1_-y2_);
    32         printf("%d %d %d %d
    ",x1_+d,y1_,x2_+d,y2_);
    33     }
    34     else if (y1_==y2_){
    35         int d=abs(x1_-x2_);
    36         printf("%d %d %d %d
    ",x1_,y1_+d,x2_,y2_+d);
    37     }
    38     else if(abs(x1_-x2_)==abs(y1_-y2_)){
    39         printf("%d %d %d %d
    ",x2_,y1_,x1_,y2_);
    40     }
    41     else cout<<"-1
    ";
    42     return 0;
    43 }
  • 相关阅读:
    OOP & Pointer: Segment Tree
    ICPC_2020 上海站
    Notes: Kirchhoff's Matrix 基尔霍夫矩阵
    CS61A Homework: Church Numerals
    题解:[COCI2011-2012#5] BLOKOVI
    题解:SDOI2017 新生舞会
    题解:POI2012 Salaries
    题解:洛谷P1357 花园
    题解:CF593D Happy Tree Party
    题解 P2320 【[HNOI2006]鬼谷子的钱袋】
  • 原文地址:https://www.cnblogs.com/wydxry/p/7260254.html
Copyright © 2011-2022 走看看