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

WA on test 2,plz help !
Posted by milon603 27 Apr 2019 14:58

#include<stdio.h>
#include<math.h>
#define PI acos(-1)
int main()
{
    int N,i;
    double r;
    scanf("%d%lf",&N,&r);
    double xx,yy,cx,cy,fx,fy,sum=0,tsum=0,y,x,z;
    y=2*r;
    x=PI*r/2.0;
    z=N*(y-x);
    scanf("%lf%lf",&xx,&yy);
    fx=xx;
    fy=yy;
    for(i=2;i<=N;i++)
    {
        scanf("%lf%lf",&cx,&cy);
        sum=y+sum+sqrt((xx-cx)*(xx-cx)+(yy-cy)*(yy-cy));
        xx=cx;
        yy=cy;
        if(i==N)
        {
            sum=y+sum+sqrt((xx-fx)*(xx-fx)+(yy-fy)*(yy-fy));
            break;
        }
    }
    tsum=sum-z;
    printf("%.2lf\n",tsum);
    return 0;
}
Re: WA on test 2,plz help !
Posted by milon603 27 Apr 2019 15:00
what is the test 2..?