|
|
back to boardCommon Boardgarland: why WA the following program seems to be correct (at least, it passed all the tests i've managed to think out).But it gets WA#3.?? program garland; {$APPTYPE CONSOLE} var n,a,p,tp,dif:double; i:longint; function f(x:double):double; begin f:=x*x+tp*x+a; end; begin read(n,a); p:=-2*sqrt(a); dif:=10; for i:=1 to 1000 do begin dif:=dif/2; tp:=p-dif; if (f(trunc(-tp/2))>=0) and (f(trunc(-tp/2)+1)>=0) then p:=tp; end; tp:=p; write(f(n-1):0:2); end. Edited by author 28.02.2005 19:45 |
|
|