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

halp me please
Posted by Zamesova 19 Dec 2012 15:09
Program NoName;
var n,r,i:integer;
x: array [1..100] of real;
y: array [1..100] of real;
s,sg:real;
input,output:text;

begin
s:=0;
   assign(input, 'input.txt');
   reset(input);
   assign(output, 'output.txt');
   rewrite(output);


readln(n,r);
 if n=1 then writeln(1.00)else begin
   For i:=1 to n do
  readln(x[i],y[i]);
sg:=2*pi*r;
For i:=1 to n-1 do  s:=s+sqrt(sqr(x[i]-x[i+1])+sqr(y[i]-y[i+1]));
s:=s+sqrt(sqr(x[n]-x[1])+sqr(y[n]-y[1]));
s:=s+sg;
end;
writeln(s:1:2);
   close(input);
   close(output);
end.
Re: halp me please
Posted by morbidel 19 Dec 2012 15:25
First, remove the read and write in the txt files, you need to read/write from/to the console.
You'll get WA3 now.
Try to re-think the case when n=1; the answer is not always 1!