|
|
back to boardDiscussion of Problem 1020. RopeHelp! Why my answer's wrong? Posted by meoden 26 Feb 2002 22:02 It's seem not hard. But I always get WA. type point=record x,y:real; end; var p1,p2,p3:point; r,kc:real; i,n:integer; begin readln(n,r); if n=1 then begin writeln(2*r*pi:0:2); end else if n=2 then begin readln(p1.x,p1.y); readln(p2.x,p2.y); kc:=sqrt(sqr(p1.x-p2.x)+sqr(p1.y-p2.y)); writeln((2*r*pi+kc*2):0:2); end else begin readln(p1.x,p1.y); p2:=p1; for i:=2 to n do begin readln(p3.x,p3.y); kc:=kc+sqrt(sqr(p3.x-p2.x)+sqr(p3.y-p2.y)); p2:=p3; end; kc:=kc+sqrt(sqr(p1.x-p3.x)+sqr(p1.y-p3.y)); kc:=kc+(n-2)*r*pi; writeln(kc:0:2); end; end. Wrong ! Wrong! > It's seem not hard. But I always get WA. > > type point=record > x,y:real; > end; > var p1,p2,p3:point; > r,kc:real; > i,n:integer; > > begin > readln(n,r); > if n=1 then > begin > writeln(2*r*pi:0:2); > end > else > if n=2 then > begin > readln(p1.x,p1.y); > readln(p2.x,p2.y); > kc:=sqrt(sqr(p1.x-p2.x)+sqr(p1.y-p2.y)); > writeln((2*r*pi+kc*2):0:2); > end > else > begin > readln(p1.x,p1.y); > p2:=p1; > for i:=2 to n do > begin > readln(p3.x,p3.y); > kc:=kc+sqrt(sqr(p3.x-p2.x)+sqr(p3.y-p2.y)); > p2:=p3; > end; > kc:=kc+sqrt(sqr(p1.x-p3.x)+sqr(p1.y-p3.y)); > > kc:=kc+(n-2)*r*pi; ---> Kc := Kc + 2*r*pi; { ********} > writeln(kc:0:2); > end; > end. Read this Posted by Aidar 27 Feb 2002 06:43 Dear Meoden! I give you solution of this simple program and you give me solution of 1118! (aidar@ufa.ru) var r, P : extended; a : array [1..101] of record x, y : extended; end; n, i : byte; begin ReadLn (n, r); for i := 1 to n do with a [i] do ReadLn (x, y); with a [n + 1] do begin x := a [1].x; y := a [1].y; end; P := 2 * pi * r; for i := 1 to n do P := P + sqrt (sqr (a [i + 1].x - a [i].x) + sqr (a [i + 1].y - a [i].y)); WriteLn (P:0:2); end. Thanks Aidar Thanks Aidar Very Nice I see you have solved 1118 already which one can i help you? Thanks Aidin_n7@hotmail.com |
|
|