1. 程式人生 > >Codeforces Round #388 (Div. 2) B

Codeforces Round #388 (Div. 2) B

special def contain coo parallel mes c++ clu tps

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 x

i 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 }

Codeforces Round #388 (Div. 2) B