[BZOJ1024][SCOI2009]生日快乐 搜索
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1024
直接xjb搜索。
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 double s; 6 double dfs(double x,double y,int k){ 7 if(k==1) return x>y?(x/y):(y/x); 8 double ret=2333333,nx=x/k,ny=y/k; 9 for(int i=1;i<=(k>>1);i++){ 10 ret=min(max(dfs(nx*i,y,i),dfs(x-nx*i,y,k-i)),ret); 11 if(x!=y) ret=min(max(dfs(x,ny*i,i),dfs(x,y-ny*i,k-i)),ret); 12 } 13 return ret; 14 } 15 int main(){ 16 double x,y; 17 int n; 18 scanf("%lf%lf%d",&x,&y,&n); 19 s=x*y/n; 20 printf("%lf\n",dfs(x,y,n)); 21 return 0; 22 }