Tinamei
其实你不知道你不知道

Run

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 736    Accepted Submission(s): 320


Problem Description
AFA is a girl who like runing.Today,he download an app about runing .The app can record the trace of her runing.AFA will start runing in the park.There are many chairs in the park,and AFA will start his runing in a chair and end in this chair.Between two chairs,she running in a line.she want the the trace can be a regular triangle or a square or a regular pentagon or a regular hexagon.
Please tell her how many ways can her find.
Two ways are same if the set of chair that they contains are same.
Input
There are multiply case.
In each case,there is a integer n(1 < = n < = 20)in a line.
In next n lines,there are two integers xi,yi(0 < = xi,yi < 9) in each line.
 

 

Output
Output the number of ways.
 

 

Sample Input
4
0 0
0 1
1 0
1 1

 

Sample Output
1
题意:一个喜欢跑步的小女孩儿在有椅子的公园里跑步。在跑步过程中,她会有选择的在椅子上休息,给定椅子位置全是整数点坐标,问以小女孩经过的长椅位置为点可能构成的正3,4,5, 6边形的情况有几种
 
既然长椅位置都是整数点坐标,那么构成正多边形的情况只有正四边形。数据范围不大,20.暴搜就行。
 1 #include<iostream>
 2 #include<algorithm>
 3 #include<cstdio>
 4 #include<cstring>
 5 
 6 using namespace std;
 7 
 8 #define N 25
 9 
10 int n;
11 
12 struct node
13 {
14     int x, y;
15 }P[N];
16 
17 int slove(int i, int j, int k, int q)    //求出4点之间所有距离,会得到4个边长,和两个对角线的长度。显然只有两个不等的量,满足条件就是正四边形
18 {
19     if(i == j || i == k)
20         return false;
21     if(i == q || j == k)
22         return false;
23     if(j == q || k == q)
24         return false;
25 
26     int w = 0, num[8];
27     memset(num, 0, sizeof(num));
28 
29     num[w++] = (P[i].x-P[j].x)*(P[i].x-P[j].x)+(P[i].y-P[j].y)*(P[i].y-P[j].y);
30     num[w++] = (P[i].x-P[k].x)*(P[i].x-P[k].x)+(P[i].y-P[k].y)*(P[i].y-P[k].y);
31     num[w++] = (P[i].x-P[q].x)*(P[i].x-P[q].x)+(P[i].y-P[q].y)*(P[i].y-P[q].y);
32     num[w++] = (P[j].x-P[k].x)*(P[j].x-P[k].x)+(P[j].y-P[k].y)*(P[j].y-P[k].y);
33     num[w++] = (P[j].x-P[q].x)*(P[j].x-P[q].x)+(P[j].y-P[q].y)*(P[j].y-P[q].y);
34     num[w++] = (P[q].x-P[k].x)*(P[q].x-P[k].x)+(P[q].y-P[k].y)*(P[q].y-P[k].y);
35 
36     sort(num, num+w);
37 
38     w = unique(num, num+w) - num;
39 
40     if(w != 2)
41         return false;
42     return true;
43 }
44 
45 int main()
46 {
47     while(scanf("%d", &n) != EOF)
48     {
49         int ans = 0;
50 
51         for(int i = 1; i <= n; i++)
52             scanf("%d%d", &P[i].x, &P[i].y);
53 
54         for(int i = 1; i <= n; i++)
55             for(int j = i+1; j <= n; j++)
56                 for(int k = j+1; k <= n; k++)
57                     for(int q = k+1; q <= n; q++)
58                         if(slove(i, j, k, q))    // 判断是否是正四边形
59                             ans++;
60 
61         printf("%d\n", ans);
62     }
63     return 0;
64 }

其实你不知道你不知道

posted on 2015-08-10 09:22  Tinamei  阅读(152)  评论(0)    收藏  举报