标签:star each mission eps can -- tom mil blog
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 2002 Accepted Submission(s): 1168
1 #include <iostream> 2 #include <string> 3 #include <cstdio> 4 #include <cstring> 5 #include <algorithm> 6 #include <climits> 7 #include <cmath> 8 #include <vector> 9 #include <queue> 10 #include <stack> 11 #include <set> 12 #include <map> 13 using namespace std; 14 typedef long long LL ; 15 typedef unsigned long long ULL ; 16 const int maxn = 1e2 + 10 ; 17 const int inf = 0x3f3f3f3f ; 18 const int npos = -1 ; 19 const int mod = 1e9 + 7 ; 20 const int mxx = 100 + 5 ; 21 const double eps = 1e-6 ; 22 const double PI = acos(-1.0) ; 23 24 struct node{ 25 double x, y; 26 node(double a=0LL, double b=0LL){ 27 x=a; y=b; 28 } 29 }; 30 node vex[maxn], center; 31 node CircumCenter(node a, node b, node c){ 32 double a1=b.x-a.x, b1=b.y-a.y, c1=(a1*a1+b1*b1)/2; 33 double a2=c.x-a.x, b2=c.y-a.y, c2=(a2*a2+b2*b2)/2; 34 double d=a1*b2-a2*b1; 35 return node(a.x+(c1*b2-c2*b1)/d,a.y+(a1*c2-a2*c1)/d); 36 } 37 double dis2(node a, node b){ 38 return pow(a.x-b.x,2)+pow(a.y-b.y,2); 39 } 40 bool oneLine(node a, node b, node c){ 41 return ((b.y-a.y)/(b.x-a.x))==((c.y-a.y)/(c.x-a.x)); 42 } 43 int T, n, ans; 44 double R, D[maxn][maxn]; 45 int main(){ 46 // freopen("in.txt","r",stdin); 47 // freopen("out.txt","w",stdout); 48 while(~scanf("%d",&T)){ 49 while(T--){ 50 ans=1; 51 scanf("%d",&n); 52 for(int i=1;i<=n;i++) 53 scanf("%lf %lf",&vex[i].x,&vex[i].y); 54 55 if(oneLine(vex[1],vex[2],vex[3])) 56 ans=0; 57 58 if(ans){ 59 center=CircumCenter(vex[1],vex[2],vex[3]); 60 R=dis2(center,vex[1]); 61 for(int i=1;i<=n;i++) 62 if(dis2(vex[i],center)!=R){ 63 ans=0; break; 64 } 65 } 66 67 if(ans){ 68 for(int i=1;i<=n;i++){ 69 D[i][i]=0.0; 70 for(int j=i+1;j<=n;j++) 71 D[i][j]=D[j][i]=dis2(vex[i],vex[j]); 72 sort(D[i]+1,D[i]+1+n); 73 } 74 for(int i=2;i<=n;i++) 75 if(!(D[i][2]==D[i][3] && D[i][2]==D[i-1][2])){ 76 ans=0; break; 77 } 78 } 79 puts(ans?"YES":"NO"); 80 } 81 } 82 return 0; 83 }
标签:star each mission eps can -- tom mil blog
原文地址:http://www.cnblogs.com/edward108/p/7637297.html