简单几何(水)BestCoder Round #50 (div.2) 1002 Run

 

题目传送门

 1 /*
 2     好吧,我不是地球人,这题只要判断正方形就行了,正三角形和正五边形和正六边形都不可能(点是整数)。
 3     但是,如果不是整数,那么该怎么做呢?是否就此开启计算几何专题了呢
 4 */
 5 /************************************************
 6  * Author        :Running_Time
 7  * Created Time  :2015-8-8 19:54:14
 8  * File Name     :B.cpp
 9  ************************************************/
10 
11 #include <cstdio>
12 #include <algorithm>
13 #include <iostream>
14 #include <sstream>
15 #include <cstring>
16 #include <cmath>
17 #include <string>
18 #include <vector>
19 #include <queue>
20 #include <deque>
21 #include <stack>
22 #include <list>
23 #include <map>
24 #include <set>
25 #include <bitset>
26 #include <cstdlib>
27 #include <ctime>
28 using namespace std;
29 
30 #define lson l, mid, rt << 1
31 #define rson mid + 1, r, rt << 1 | 1
32 typedef long long ll;
33 const int MAXN = 22;
34 const int INF = 0x3f3f3f3f;
35 const int MOD = 1e9 + 7;
36 struct Point    {
37     int x, y;
38 }p[MAXN];
39 int id[10];
40 int n, tot;
41 
42 int cal_dis(int x1, int y1, int x2, int y2)    {
43     return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
44 }
45 
46 bool judge(void) {
47     int tt = 0; int d[20];
48     for (int i=1; i<=4; ++i)    {
49         for (int j=i+1; j<=4; ++j)  {
50             d[++tt] = cal_dis (p[id[i]].x, p[id[i]].y, p[id[j]].x, p[id[j]].y);
51         }
52     }
53     sort (d+1, d+1+tt);
54     for (int i=1; i<=3; ++i)    if (d[i] != d[i+1]) return false;
55     if (d[5] != d[6])   return false;
56     if (d[5] != d[1] * 2)   return false;
57     return true;
58 }
59 
60 void DFS(int s, int num)    {
61     if (num == 4)   {
62         if (judge ())    tot++;
63         return ;
64     }
65     for (int i=s+1; i<=n; ++i)  {
66         id[num+1] = i;
67         DFS (i, num + 1);
68     }
69 }
70 
71 void work(void) {
72     tot = 0;
73     DFS (0, 0);
74     printf ("%d\n", tot);
75 }
76 
77 int main(void)    {     //BestCoder Round #50 (div.2) 1002 Run
78     while (scanf ("%d", &n) == 1)   {
79         for (int i=1; i<=n; ++i)    {
80             scanf ("%d%d", &p[i].x, &p[i].y);
81         }
82         if (n < 3)  {
83             puts ("0"); continue;
84         }
85         work ();
86     }
87 
88     return 0;
89 }

 

posted @ 2015-08-09 08:34  Running_Time  阅读(191)  评论(0编辑  收藏  举报