标签:des c style class blog code
Time Limit: 2000/1000 MS
(Java/Others) Memory Limit: 65536/32768 K
(Java/Others)
Total Submission(s): 5203 Accepted
Submission(s): 2155
1 //15MS 376K 695 B C++ 2 #include<stdio.h> 3 #include<math.h> 4 #define N 1000005 5 struct node{ 6 double x,y; 7 }p[N]; 8 double getsum(node a,node b,node c) 9 { 10 return ((b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y))/2.0; 11 } 12 int main(void) 13 { 14 int t,n; 15 scanf("%d",&t); 16 while(t--) 17 { 18 scanf("%d",&n); 19 for(int i=0;i<n;i++) 20 scanf("%lf%lf",&p[i].x,&p[i].y); 21 double ss=0,sx=0,sy=0; 22 for(int i=0;i<n-2;i++){ 23 double ts=getsum(p[0],p[i+1],p[i+2]); 24 ss+=ts; 25 sx+=ts*(p[0].x+p[i+1].x+p[i+2].x); 26 sy+=ts*(p[0].y+p[i+1].y+p[i+2].y); 27 } 28 printf("%.2lf %.2lf\n",sx/ss/3,sy/ss/3); 29 } 30 return 0; 31 }
hdu 1115 Lifting the Stone (数学几何),布布扣,bubuko.com
hdu 1115 Lifting the Stone (数学几何)
标签:des c style class blog code
原文地址:http://www.cnblogs.com/GO-NO-1/p/3764152.html