Just another WA prog needing help :) Послано ValBG 12 фев 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. Re: Just another WA prog needing help :) 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. Re: Just another WA prog needing help :) Послано ValBG 12 фев 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 :) 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); 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. |