WHY I GOT "WA"??? Heeeeelp!
Послано
Serrg 10 фев 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.