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

Yes! I found why my submition gives WA - but can't understand why.
Posted by Michael Medvedev (KNU training center) 26 Apr 2003 01:01
Yes! I found why my submition gives WA - but can't understand why.

Here is my WA solution:

program p1020;
var
  i,n:integer;
  r,res,a0,b0,a1,b1,a2,b2:double;
begin
  read(n,r);
  read(a1,b1);
  res:=0.0; a0 := a1; b0:=b1;
  for i:=1 to n-1 do
  begin
    readln(a2,b2);
    res := res + sqrt((a2-a1)*(a2-a1)+(b2-b1)*(b2-b1));
    a1 := a2; b1:=b2;
  end;
  res := res + sqrt((a2-a0)*(a2-a0)+(b2-b0)*(b2-b0));
  res := res + 2*PI*r;
  writeln(res:0:2);
end.

!!!! BUT when I  change a line
    res := res + sqrt((a2-a0)*(a2-a0)+(b2-b0)*(b2-b0));
to
    res := res + sqrt((a1-a0)*(a1-a0)+(b1-b0)*(b1-b0));
I get ACCEPTED!!!

Tell me smb, WHY?????
Because for N=1 your first program is wrong (+)
Posted by Dmitry 'Diman_YES' Kovalioff 26 Apr 2003 16:03
Try this input:

1 1
2 2

Output should be 6.28, but your first program outputs 9.11
TTTTTTTTTTttttthank YYYYYYYYYYYYYYYYou very much. I had made such a mistake!!!
Posted by Seany 6 Aug 2003 17:50
> Try this input:
>
> 1 1
> 2 2
>
> Output should be 6.28, but your first program outputs 9.11