| Discussion of Problem 1020. RopeJust another WA prog needing help :) Posted by ValBG  12 Feb 2003 03:11Here's my prog: I tried it with or without (input,output); with realand 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.
Re: Just another WA prog needing help :) It looks fine to me . If you want an acc sorce (in C) send me anemail . 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.
Re: Just another WA prog needing help :) Posted by ValBG  12 Feb 2003 19:2910x 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 :)The problem is your definition of PI, is not exact as 2*asin(1) :) (-) > Here's my prog: I tried it with or without (input,output); withreal
 > 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.
 |