ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1020. Rope

Why 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;
 }