标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1047 Accepted Submission(s): 459
#include<iostream> #include<algorithm> #include<cstdio> #include<cstring> using namespace std; #define N 25 int n; struct node { int x, y; }P[N]; int slove(int i, int j, int k, int q) { if(i == j || i == k) return false; if(i == q || j == k) return false; if(j == q || k == q) return false; int w = 0, num[8]; memset(num, 0, sizeof(num)); 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); 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); 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); 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); 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); 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); sort(num, num+w); w = unique(num, num+w) - num; if(w != 2) return false; return true; } int main() { while(scanf("%d", &n) != EOF) { int ans = 0; for(int i = 1; i <= n; i++) scanf("%d%d", &P[i].x, &P[i].y); for(int i = 1; i <= n; i++) for(int j = i+1; j <= n; j++) for(int k = j+1; k <= n; k++) for(int q = k+1; q <= n; q++) if(slove(i, j, k, q)) ans++; printf("%d\n", ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/Tinamei/p/4944897.html