hdu 1115 Lifting the Stone
//31MS 240K 799 B C++ //数学,平面薄板面积公式 #include<stdio.h> struct node{ double x,y; }; double Area(node a,node b,node c) //三点面积公式 { return ((b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y))/2; } int main() { int t,n; double a,b; scanf("%d",&t); while(t--) { double sum_area=0; double sum_x=0; double sum_y=0; node p0,p1,p2; scanf("%d",&n); scanf("%lf%lf",&p0.x,&p0.y); scanf("%lf%lf",&p1.x,&p1.y); for(int i=2;i<n;i++){ scanf("%lf%lf",&p2.x,&p2.y); double area=Area(p0,p1,p2); sum_area+=area; sum_x+=(p0.x+p1.x+p2.x)*area; sum_y+=(p0.y+p1.y+p2.y)*area; p1=p2; } printf("%.2lf %.2lf\n",sum_x/sum_area/3,sum_y/sum_area/3); } return 0; }