Codeforces 749B:Parallelogram is Back(计算几何)

http://codeforces.com/problemset/problem/749/B

题意:已知平行四边形三个顶点,求另外一个顶点可能的位置。

思路:用向量来做。

 1 #include <cstdio>
 2 #include <algorithm>
 3 #include <iostream>
 4 #include <cstring>
 5 #include <string>
 6 #include <cmath>
 7 #include <queue>
 8 #include <vector>
 9 #include <map>
10 #include <set>
11 using namespace std;
12 #define INF 0x3f3f3f3f
13 #define N 100010
14 typedef long long LL;
15 struct node {
16     int x, y;
17     node () {}
18     node (int x, int y) : x(x), y(y) {}
19 }a[3], ans[3];
20 
21 int main() {
22     for(int i = 0; i < 3; i++) scanf("%d%d", &a[i].x, &a[i].y);
23     ans[0].x = a[0].x + a[1].x - a[2].x;
24     ans[0].y = a[0].y + a[1].y - a[2].y;
25     ans[1].x = a[0].x - a[1].x + a[2].x;
26     ans[1].y = a[0].y - a[1].y + a[2].y;
27     ans[2].x = a[1].x + a[2].x - a[0].x;
28     ans[2].y = a[1].y + a[2].y - a[0].y;
29     printf("3
");
30     for(int i = 0; i < 3; i++) printf("%d %d
", ans[i].x, ans[i].y);
31     return 0;
32 }
原文地址:https://www.cnblogs.com/fightfordream/p/6201884.html