zoukankan      html  css  js  c++  java
  • Codeforces Round #388 (Div. 2) B

    Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal.

    Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points.

    Input

    The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide.

    Output

    First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices.

    Then print k lines, each containing a pair of integer — possible coordinates of the fourth point.

    Example
    input
    0 0
    1 0
    0 1
    output
    3
    1 -1
    -1 1
    1 1
    Note

    If you need clarification of what parallelogram is, please check Wikipedia page:

    https://en.wikipedia.org/wiki/Parallelogram

    题意:告诉我们平行四边形三个点,让求最后一个点

    解法:

    1 当然也会存在三个点

    2 我们这样..

      y3-(y1+y2)/2得出到对角线的距离 

     我们求对角线的另外一点(y1+y2)/2+(y1+y2)/2-y3==y1+y2-y3

    3 好了,应该发现这个规律应该是,,,,yi+yj-yz和xi+xj-xz(i,j,z<=3)

     1 #include<bits/stdc++.h>
     2 typedef long long LL;
     3 typedef unsigned long long ULL;
     4 typedef long double LD;
     5 using namespace std;
     6 #define debug(x) cout << #x" = " << x<<endl;
     7 struct Node{
     8     int x,y;
     9 }node[100];
    10 int main(){
    11     for(int i=1;i<=3;i++){
    12         cin>>node[i].x>>node[i].y;
    13     }
    14     cout<<"3"<<endl;
    15     cout<<node[1].x+node[2].x-node[3].x<<" "<<node[1].y+node[2].y-node[3].y<<endl;
    16     cout<<node[2].x+node[3].x-node[1].x<<" "<<node[2].y+node[3].y-node[1].y<<endl;
    17     cout<<node[1].x+node[3].x-node[2].x<<" "<<node[1].y+node[3].y-node[2].y<<endl;
    18     return 0;
    19 }
  • 相关阅读:
    算法练习-寻找和为定值的两个数
    算法练习-字符串全排列
    算法练习-最长回文子串
    判断一点是否在三角形的外接圆内
    用递归方法计算行列式的值
    算法练习-回文判断
    算法练习-字符串转换成整数(实现atoi函数)
    算法练习-字符串包含
    数据结构-队列
    结构体(或者联合体)变量的成员在内存里是如何分布的
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/7220153.html
Copyright © 2011-2022 走看看