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 it is wrong answer???sad...
Posted by xinxin 24 Sep 2016 12:19
#include<stdio.h.>
#include<string.h>
#include<math.h>

int main()
{
    double len=0;
    int n,r,i,j;
    scanf("%d %d",&n,&r);
    double a[200][2];
    for(i=0;i<n;i++)
        for(j=0;j<2;j++)
            scanf("%lf",&a[i][j]);
    for(i=1;i<n;i++)
        len=len+sqrt((a[i][1]-a[i-1][1])*(a[i][1]-a[i-1][1])+(a[i][0]-a[i-1][0])*(a[i][0]-a[i-1][0]));
    len=len+sqrt((a[i-1][1]-a[0][1])*(a[i-1][1]-a[0][1])+(a[i-1][0]-a[0][0])*(a[i-1][0]-a[0][0]));
    len=len+3.141*2*r;
    printf("%.2lf",len);
    fflush(stdin);
    getchar();
    return 0;
}
Re: why it is wrong answer???sad...
Posted by V.Leo 10 Oct 2016 09:40
I guess the 8th and 9th line.
The value of radius is a real number instead of an integer, which is considered to be with decimal point. Thus "double r;" "scanf("%d %lf", ..)" maybe works.
Re: why it is wrong answer???sad...
Posted by ToadMonster 10 Oct 2016 19:02
Also note.
Is pi=3.141 accurate enough? I used 3.14159 in my AC program