|
|
back to boardDiscussion of Problem 1020. RopeWhy I get WA,here is my code Posted by final 12 Feb 2002 21:06 #include <iostream.h> #include <math.h> const double pi=3.1415926; void main() { double x1,y1,bx,by,nx,ny,r; int n; cin>>n>>r; cin>>x1>>y1; bx=x1; by=y1; double ans=0,dis; for(int i=2;i<=n;i++) { cin>>nx>>ny; dis=sqrt( bx-nx)*(bx-nx)+(by-ny)*(by-ny) ); ans=ans+dis; bx=nx; by=ny; } if(n>1) { ans=ans+sqrt( (nx-x1)*(nx-x1)+(ny-y1)*(ny-y1) ); } ans=ans+2*pi*r; cout.precision(2); cout<<ans<<endl; } |
|
|