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 am i gettint wrong answer ?
Posted by Costel::icerapper@k.ro 27 Feb 2002 13:08
program timus_1020;
const
  maxn=100;
var
  n:longint;
  r:real;
  x0,y0,x1,y1,x2,y2:real;
  i:longint;
  l:real;

function dist(x1,y1,x2,y2:real):real;
begin
  dist:=sqrt(sqr(x1-x2)+sqr(y1-y2));
end;

begin
assign(input,'p1020.in');reset(input);
  readln(n,r);
  l:=2*pi*r;
  readln(x0,y0);x2:=x0;y2:=y0;
  for i:=2 to n do
  begin
    x1:=x2;
    y1:=y2;
    readln(x2,y2);
    l:=l+dist(x1,y1,x2,y2);
  end;
  l:=l+dist(x0,y0,x2,y2);
  writeln(l:0:2);
end.
Change readln to read and you will get AC!
Posted by MadPsyentist/Sam 28 Feb 2002 03:58
> program timus_1020;
> const
>   maxn=100;
> var
>   n:longint;
>   r:real;
>   x0,y0,x1,y1,x2,y2:real;
>   i:longint;
>   l:real;
>
> function dist(x1,y1,x2,y2:real):real;
> begin
>   dist:=sqrt(sqr(x1-x2)+sqr(y1-y2));
> end;
>
> begin
> assign(input,'p1020.in');reset(input);
>   readln(n,r);
>   l:=2*pi*r;
>   readln(x0,y0);x2:=x0;y2:=y0;
>   for i:=2 to n do
>   begin
>     x1:=x2;
>     y1:=y2;
>     readln(x2,y2);
>     l:=l+dist(x1,y1,x2,y2);
>   end;
>   l:=l+dist(x0,y0,x2,y2);
>   writeln(l:0:2);
> end.