标签:des style blog http java color
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 688 Accepted Submission(s): 178
#include <iostream> #include <stdio.h> #include <math.h> #include <string.h> using namespace std; const double esp = 1e-10; #define N 1005 char str[10]; int i,j,k; struct Point{ double x,y; Point(double x = 0,double y = 0):x(x),y(y){} }; struct Circle{ Point A; double r; }c[N]; struct Triangles{ Point A,B,C; }t[N]; struct Rectangles{ Point A,B; }r[N]; typedef Point Vector; Vector operator - (Vector A ,Vector B) {return Vector(A.x-B.x,A.y-B.y);} double Dot(Vector A ,Vector B) {return A.x*B.x+A.y*B.y;} double Length(Vector A) {return sqrt(Dot(A,A));} double Cross(Vector A,Vector B) {return A.x*B.y-A.y*B.x;} int judge(Point A) { int p = 0,count = 0; for(p = 0 ; p < i ; p++) if(Length(A-c[p].A)<=c[p].r) count++; for(p = 0 ; p < k ; p++) if(A.x<=r[p].B.x&&A.y<=r[p].B.y&&A.x>=r[p].A.x&&A.y>=r[p].A.y) count++; for(p = 0 ; p < j ; p++) { if(Cross(t[p].C-t[p].B,t[p].A-t[p].B)*Cross(A-t[p].B,t[p].A-t[p].B)>0&& Cross(t[p].A-t[p].C,t[p].B-t[p].C)*Cross(A-t[p].C,t[p].B-t[p].C)>0&& Cross(t[p].B-t[p].A,t[p].C-t[p].A)*Cross(A-t[p].A,t[p].C-t[p].A)>0) count++; } return count; } int main() { int s,n,ans1 = 0,ans2 = 0;i = j = k =0; scanf("%d",&s); while(s--) { scanf("%s",str); if(str[0] == ‘C‘){ scanf("%lf %lf %lf",&c[i].A.x,&c[i].A.y,&c[i].r);i++; }else if(str[0] == ‘T‘){ scanf("%lf %lf %lf %lf %lf %lf",&t[j].A.x,&t[j].A.y,&t[j].B.x,&t[j].B.y,&t[j].C.x,&t[j].C.y);j++; }else { scanf("%lf %lf %lf %lf",&r[k].A.x,&r[k].A.y,&r[k].B.x,&r[k].B.y);k++; } } scanf("%d",&n); Point A; int p = 0; while(n--) { ans1 = ans2 = 0; for(p = 0 ; p < 3 ; p++) { scanf("%lf %lf",&A.x,&A.y); ans1+=judge(A); } for(p = 0 ; p < 3 ; p++) { scanf("%lf %lf",&A.x,&A.y); ans2+=judge(A); } if(ans1<ans2) printf("Hannah\n"); else if(ans1>ans2) printf("Bob\n"); else printf("Tied\n"); } return 0; }
标签:des style blog http java color
原文地址:http://www.cnblogs.com/llei1573/p/3847583.html