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 }
  • 相关阅读:
    多播(组播)与广播的技术实现
    (转)单播、多播(组播)和广播的区别
    (转)简述负载均衡&CDN技术
    当领导得学会骂下属的艺术
    CSDN首页> 云计算 孙玄:解析58同城典型技术架构及演变
    VMware网络连接 桥接、NAt、host-only模式 .
    dajian
    [Android开发常见问题-4] RunTime.exec()如何以root权限执行多条指令?
    Android获取Root权限之后的静默安装实现代码示例分析
    Android
  • 原文地址:https://www.cnblogs.com/wydxry/p/7260254.html
Copyright © 2011-2022 走看看