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 |
Re:贴程序In Reply To:贴程序 Posted by:frkstyc at 2005-07-23 22:07:32 #include<stdio.h> #include<math.h> #define PI acos(-1.0) #define EP 1e-8 int n,r; struct TPoint { double x,y; }; TPoint point[1001]; double AreaOfPolygon(TPoint P[], int n) { int i; double s = 0.0; if (n < 3) return 0.0; for (i = 0; i < n; i++) s += P[i].x * P[(i + 1) % n].y - P[i].y * P[(i + 1) % n].x; return fabs(s) / 2.0; } int main() { freopen("a.in","r",stdin); double len=0.0; int i; scanf("%d %d",&n,&r); for(i=0;i<n;i++) { scanf("%lf %lf",&point[i].x,&point[i].y); } len = AreaOfPolygon(point, n); if(n>=2) len +=2.0*PI*r; if(n==2) len+=(point[0].x-point[1].x)*(point[0].x-point[1].x)+(point[0].y-point[1].y)*(point[0].y-point[1].y); printf("%.2lf\n",len); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator