ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

garland: why WA
Posted by jedimastex 28 Feb 2005 19:43
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