Discussion of Problem 1020. RopeWhy am i gettint wrong answer ? 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! > 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. |