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 }
  • 相关阅读:
    UPC OJ 一道水题 STL
    POJ2387 Til the Cows Come Home(SPFA + dijkstra + BallemFord 模板)
    HD1385Minimum Transport Cost(Floyd + 输出路径)
    POJ1679The Unique MST(次小生成树)
    POJ 1789Truck History(pirme)
    POJ2309BST(树状数组)
    POJ2299Ultra-QuickSort(归并排序 + 树状数组求逆序对)
    POJ2531Network Saboteur(DFS+剪枝)
    Codeforce#331 (Div. 2) A. Wilbur and Swimming Pool(谨以此题来纪念我的愚蠢)
    POJ2485Highways(prime 水题)
  • 原文地址:https://www.cnblogs.com/wydxry/p/7260254.html
Copyright © 2011-2022 走看看