|
|
back to boardDiscussion of Problem 1020. RopeRepeatedly WA on test 3. I think i'm gonna crack! Posted by xerxe 17 Dec 2006 04:27 #define PI2 6.283185307179586476925286766559 #include <iostream> #include <math.h> using namespace std; void main(){ int N, i; float R, x[100], y[100], L; L=0.0f; cin>>N>>R; if (N==0){ cout<<"0"; return;} for(i=0; i<N; i++){ cin>>float(x[i])>>float(y[i]); if (i) L+=sqrt( (x[i-1]-x[i])*(x[i-1]-x[i])+(y[i-1]-y[i])*(y[i-1]-y[i]) ); } L+=sqrt( (x[i-1]-x[0])*(x[i-1]-x[0])+(y[i-1]-y[0])*(y[i-1]-y[0]) ); L+=PI2*R; if (N==1) L=PI2*R; L*=100; L=int(L); L/=100; cout<<L; } On my tests, it works ok. The length is truncated, not rounded. It works for 0, 1, 2, ... nails. I can't see what's wrong. And it's getting quite frustrating. If someone could help me with an idea as to why i get WA on test 3, I would remain in their debt. Thanks. Re: Repeatedly WA on test 3. I think i'm gonna crack! Use this for writing result: printf("%.2f", L); instead of L*=100; L=int(L); L/=100; cout<<L; Edited by author 18.12.2006 03:23 Re: Repeatedly WA on test 3. I think i'm gonna crack! Posted by xerxe 18 Dec 2006 18:56 Whew!! Thanks a lot. It worked. I had the same issue in another problem. I'll change there, too. Again, thank you very much. Re: Repeatedly WA on test 3. I think i'm gonna crack! Thank U!!!!!)) I has WA because of L*=100; L=int(L); L/=100; cout<<L; not printf() )) Re: Repeatedly WA on test 3. I think i'm gonna crack! what's wrong with this ? var n,k: byte; r,x0,y0,x1,y1,x,y: Real; s: real; begin readln(n,r); s:=r*6.28; if n=0 then s:=0; if n=2 then begin readln(x0,y0); readln(x1,y1); s:=s+2*sqrt(sqr(x1-x0)+sqr(y1-y0)); end; if n>2 then begin readln(x0,y0); x:=x0; y:=y0; for k:=1 to n-1 do begin readln(x1,y1); s:=s+sqrt(sqr(x1-x0)+sqr(y1-y0)); x0:=x1; y0:=y1; end; s:=s+sqrt(sqr(x-x0)+sqr(y-y0)); end; writeln(int(s*100)/100:0:2); end. i got WA on test #3 i tried writeln(s:0:2); also, got WA Edited by author 21.10.2009 00:48 |
|
|