Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么是WA呢?难道精度有问题?算法是参照佳佳书上的。。。#include<stdio.h> int xi,yi,xj,yj,x1,y1; __int64 cx,cy,area; int main() { int t,n,i; scanf("%d",&t); while(t--) { area=0; cx=cy=0; scanf("%d",&n); scanf("%d%d",&x1,&y1); xi=x1; yi=y1; for(i=1;i<n;i++) { scanf("%d%d",&xj,&yj); area+=xi*yj-yi*xj; cx+=(xi+xj)*(xi*yj-yi*xj); cy+=(yi+yj)*(xi*yj-yi*xj); xi=xj; yi=yj; } area+=xi*y1-yi*x1; cx+=(xi+x1)*(xi*y1-yi*x1); cy+=(yi+y1)*(xi*y1-yi*x1); printf("%.2lf %.2lf\n",cx/3.0/area,cy/3.0/area); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator