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

Anyone who can help me to find out the wrong place?It seems to be right,but WA. on test 5..thanks
Posted by yoyoo 30 Jun 2004 20:42
I searched the forum,and used the data you offered.It seems to be all right,but wa on test 5...
my code shown below,thx:)

{$N+}

var
   a,b:extended;
   total:longint;
   i,j:longint;
   max,now:extended;
   x,y,key1,key2:extended;
begin
  readln(a,b);
  readln(total);
  close(input);
  max:=-1;
  for i:=0 to total do
   begin
     x:=round((a-b+2*i)/4);
     y:=i-x;
     now:=a*x+b*y-x*x-y*y;
     if now>max then
     begin
       max:=now;
       key1:=x;
       key2:=y;
     end
     else if now=max then
      if y<key2 then
      begin
       key1:=x;
       key2:=y;
      end;
   end;
   writeln(max:0:2);
   write(KEY1:0:0,' ',KEY2:0:0);
end.