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:能不能多给一些测试数据哦,总是WA!In Reply To:能不能多给一些测试数据哦,总是WA! Posted by:hubo430 at 2006-07-14 16:27:16 > #include<stdio.h> > #include<math.h> > struct point > { > int x; > int y; > }mypoint[1000],temp,stack[3000],x,y,z; > int main() > { > int n,l,number,top,t,i,j; > while(scanf("%d%d",&n,&l)==2) > { > for(i=0;i<n;i++) scanf("%d%d",&mypoint[i].x,&mypoint[i].y); > for(i=0;i<n-1;i++) > for(j=0;j<n-1-i;j++) > if(mypoint[j].y>mypoint[j+1].y > ||(mypoint[j].y==mypoint[j+1].y&&mypoint[j].x>mypoint[j+1].x)) > { > temp=mypoint[j]; > mypoint[j]=mypoint[j+1]; > mypoint[j+1]=temp; > } > number=1;stack[0]=mypoint[0];top=0; > for(i=1;i<n;i++) > { > if(number==1) > { > number++; > top++; > stack[top]=mypoint[i]; > continue; > } > z=mypoint[i]; > y=stack[top]; > x=stack[top-1]; > t=(y.x-x.x)*(z.y-y.y)-(y.y-x.y)*(z.x-y.x); > if(t>0) > { > number++; > top++; > stack[top]=mypoint[i]; > continue; > } > top--;number--;i--; > } > for(i--;i>=0;i--) > { > for(j=0;j<=top;j++) if(stack[j].x==mypoint[i].x&&stack[j].y==mypoint[i].y) break; > if(j>top||i==0) > { > z=mypoint[i]; > y=stack[top]; > x=stack[top-1]; > t=(y.x-x.x)*(z.y-y.y)-(y.y-x.y)*(z.x-y.x); > if(t>0) > { > number++; > top++; > stack[top]=mypoint[i]; > continue; > } > top--;number--;i++; > } > } > //for(i=0;i<=top;i++) printf("%d %d\n",stack[i].x,stack[i].y); > double pi=3.1415926,sum=0; > for(i=1;i<=top;i++) > sum+=sqrt((stack[i].x-stack[i-1].x)*(stack[i].x-stack[i-1].x)+(stack[i].y-stack[i-1].y)*(stack[i].y-stack[i-1].y)); > sum+=pi*2*l; > printf("%.0lf\n",sum); > } > return 0; > } > > > > > > > > > > > > Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator