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

C++ Code - Can't find what is wrong in it ! Help Please !
Posted by Sylap 18 Aug 2012 05:17
//1020. Rope

# include <cstdio>
# include <cmath>
# include <iomanip>
# include <iostream>

using namespace std;

struct dbl{double x,y;};

int n,r;
dbl p[110];
double res;

int main()
{
   cin>>n>>r;

   for(int i=0;i<n;i++)
   cin>>p[i].x>>p[i].y;

   for(int i=1;i<n;i++)
   res+=sqrt( (p[i].x-p[i-1].x)*(p[i].x-p[i-1].x) + (p[i].y-p[i-1].y)*(p[i].y-p[i-1].y) );

   res+=sqrt( (p[0].x-p[n-1].x)*(p[0].x-p[n-1].x) + (p[0].y-p[n-1].y)*(p[0].y-p[n-1].y) );

   res+=2*r*acos(-1.0);

   printf("%.2lf",res);

   return 0;
}

Can you please tell me what is wrong in it?

Edited by author 18.08.2012 05:19

Edited by author 19.08.2012 20:03
Re: C++ Code - Can't find what is wrong in it ! Help Please !
Posted by huiyuning 29 Aug 2012 15:40
You get 2*PI*r when n is 1~
Try the case 1 1!

Edited by author 29.08.2012 15:41

Edited by author 29.08.2012 15:41