Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

ft...................................

Posted by frkstyc at 2005-07-23 22:10:48 on Problem 2365
In Reply To:Re:贴程序 Posted by:sothink at 2005-07-23 22:08:10
> #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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator