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 got CE plz help
Posted by Hemisphere 1 May 2006 19:59
#include <stdio.h>
#include <math.h>

double x[101],y[101];
int n=0;
double len=0,rad=0,pi=2*acos(0);

double dist(int n1,int n2)
{
 double d1,d2;

 if(x[n1]>=x[n2]) d1=x[n1]-x[n2];
 if(y[n1]>=y[n2]) d2=y[n1]-y[n2];
 if(x[n2]>=x[n1]) d1=x[n2]-x[n1];
 if(y[n2]>=y[n1]) d2=y[n2]-y[n1];

 if(d1==0)return d2;
 if(d2==0)return d1;

 return sqrt((d1*d1)+(d2*d2));
}

int main()
{
 int i;
 scanf("%d %lf",&n,&rad);

 for(i=1;i<=n;i++) {
      scanf("%lf %lf",&x[i],&y[i]);
 }

 for(i=1;i<n;i++) {
     len = len+dist(i,i+1);
 }

 len = len+dist(1,n);
 len = len+(2*pi*rad);

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

 return 0;
}
Enter a valid email when submitting, and you'll get a report with compiler messages (+)
Posted by Michael Rybak (accepted@ukr.net) 1 May 2006 20:53
Also, please read FAQ before asking anything else here ;)