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

ac program
Posted by saba 3 Jun 2007 15:17
var n,i:integer;
r:extended;
a:array[1..100] of record x,y:extended; end;
res:extended;
begin
read(n); read(r); res:=0;
for i:=1 to n do Readln(a[i].x,a[i].y);
for i:=2 to n do res:=res+sqrt(sqr(a[i].x-a[i-1].x)+sqr(a[i].y-a[i-
1].y));
res:=res+sqrt(sqr(a[n].x-a[1].x)+sqr(a[n].y-a[1].y));
res:=res+2*pi*r;
writeln(res:0:2);
end
Re: ac program
Posted by JIeHuH*CCCP 8 Jul 2007 03:59
Tell me plz, why res:=res+2*pi*r ?

Why not res:=res+(n-2)*pi*r for n>2

(n-2)*pi is a summ if angles
Re: ac program
Posted by Alexander Georgiev 8 Jul 2007 20:35
With equal radii of the circles it is sufficient to add one circle size to the result (which is calculated as if we have dots instead of circles). It is easy provable so I will leave that to you. If we had circles with overlapping it would be much harder, however we don't so it works =)


Edited by author 08.07.2007 20:37