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

Vallery Just another WA prog needing help :) [3] // Problem 1020. Rope 12 Feb 2003 03:11
Here's my prog: I tried it with or without (input,output); with real
and with extended type... can't see what's wrong, help pls!

Program Rope;
Const Pi=3.1415926535897932385;
Var N,i:byte;
    R,x0,y0,x1,y1,x2,y2,L:extended;

Function Length(x1,y1,x2,y2:extended):extended;
  begin
    Length:=sqrt(sqr(x2-x1)+sqr(y2-y1))
  end;

Begin
  readln(N,R);
  L:=2*Pi*R;
  readln(x0,y0);
  x1:=x0; y1:=y0;
  for i:=2 to N do
    begin
      readln(x2,y2);
      L:=L+Length(x1,y1,x2,y2);
      x1:=x2;
      y1:=y2;
    end;
  L:=L+Length(x0,y0,x2,y2);
  writeln(L:0:2);
End.
Calin Ciutu (ciutu@go.ro) Re: Just another WA prog needing help :) [1] // Problem 1020. Rope 12 Feb 2003 04:54
It looks fine to me . If you want an acc sorce (in C) send me an
email . ciutu@go.ro

> Here's my prog: I tried it with or without (input,output); with
real
> and with extended type... can't see what's wrong, help pls!
>
> Program Rope;
> Const Pi=3.1415926535897932385;
> Var N,i:byte;
>     R,x0,y0,x1,y1,x2,y2,L:extended;
>
> Function Length(x1,y1,x2,y2:extended):extended;
>   begin
>     Length:=sqrt(sqr(x2-x1)+sqr(y2-y1))
>   end;
>
> Begin
>   readln(N,R);
>   L:=2*Pi*R;
>   readln(x0,y0);
>   x1:=x0; y1:=y0;
>   for i:=2 to N do
>     begin
>       readln(x2,y2);
>       L:=L+Length(x1,y1,x2,y2);
>       x1:=x2;
>       y1:=y2;
>     end;
>   L:=L+Length(x0,y0,x2,y2);
>   writeln(L:0:2);
> End.
Vallery Re: Just another WA prog needing help :) // Problem 1020. Rope 12 Feb 2003 19:29
10x a lot :) I already posted another competitor's program and it
worked (http://acm.timus.ru/messages.asp?id=6809) though it is the
same as mine in idea... It looks like the Online Judge is quite
unpredictable :)
> Here's my prog: I tried it with or without (input,output); with
real
> and with extended type... can't see what's wrong, help pls!
>
> Program Rope;
> Const Pi=3.1415926535897932385;
> Var N,i:byte;
>     R,x0,y0,x1,y1,x2,y2,L:extended;
>
> Function Length(x1,y1,x2,y2:extended):extended;
>   begin
>     Length:=sqrt(sqr(x2-x1)+sqr(y2-y1))
>   end;
>
> Begin
>   readln(N,R);
>   L:=2*Pi*R;
>   readln(x0,y0);
>   x1:=x0; y1:=y0;
>   for i:=2 to N do
>     begin
>       readln(x2,y2);
>       L:=L+Length(x1,y1,x2,y2);
>       x1:=x2;
>       y1:=y2;
>     end;
>   L:=L+Length(x0,y0,x2,y2);
>   writeln(L:0:2);
> End.