首页 > 代码库 > SCOI2009生日快乐

SCOI2009生日快乐

竟然是搜索……囧

还以为是什么神题……

 1 uses math; 2 var x,y:extended; 3     n:longint; 4 function find(x,y:extended;z:longint):extended; 5   var i:longint; 6       r1,r2:extended; 7   begin 8   find:=10000000; 9   if z=1 then10    begin11    if x>y then exit(x/y) else exit(y/x);12    end;13   for i:=1 to z-1 do14    begin15    r1:=find(x*i/z,y,i);r2:=find(x*(z-i)/z,y,z-i);16    find:=min(find,max(r1,r2));17    end;18   for i:=1 to z-1 do19    begin20    r1:=find(x,y*i/z,i);r2:=find(x,y*(z-i)/z,z-i);21    find:=min(find,max(r1,r2));22    end;23   end;24 begin25  readln(x,y,n);26  writeln(find(x,y,n):0:6);27 end.   
View Code