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 }
  • 相关阅读:
    Log4net源码分析(一)
    ASP.NET MVC 框架是 .NET 平台 Web 开发的主流,但是并不适合初学者
    详解ASP.NET MVC应用程序请求生命周期
    ELMAH (ASP.NET错误日志处理)使用方法
    ElMAH(ASP.NET错误日志记录与通知)系列文章基础应用篇
    Log4net源码分析(三)
    Log4net 框架系列:log4net日志文件在asp.net中的应用实例记录系统错误
    ELMAH(ASP.NET错误日志记录与通知)系列文章概念篇
    Log4net源码分析(二)
    在VS2010中配制Elmah邮件发送到Gmail
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/7220153.html
Copyright © 2011-2022 走看看