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

Discussion of Problem 1200. Horns and Hoofs

WHY I GOT "WA"??? Heeeeelp!
Posted by Serrg 10 Feb 2003 18:23
This is my program:
why i got WA

var
b1,b2,func,cf:real;
k,step,a1,a2,i1,i2,t,aa1,aa2:longint;
begin
step:=10000;
a1:=5000;
a2:=5000;
cf:=0;
readln(b1,b2);
readln(k);

for t:=1 to 4 do begin
step:=step div 10;
i1:=a1-6*step;
while i1<=a1+6*step do begin
i2:=a2-6*step;
while i2<=a2+6*step do begin
if (i1+i2<=k)and(i1>=0)and(i2>=0) then begin
            func:=i1*b1+i2*b2-i1*i1-i2*i2;
            if func>cf then begin
                       cf:=func;
                       aa1:=i1;
                       aa2:=i2;
                       end;
            end;
i2:=i2+step;
end;
i1:=i1+step;
end;
a1:=aa1;
a2:=aa2;
end;
writeln(cf:0:2);
writeln(a1,' ',a2);
end.