BZOJ 1024 生日快乐

Posted on 2016-03-11 21:04  ziliuziliu  阅读(117)  评论(0编辑  收藏

深搜。

然而怎么割都有可能,所以每一种情况都要考虑。。。。。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define inf 10000007
using namespace std;
int x,y;
int n;
double solve(double x,double y,int n)
{
if (n==1) return max(x/y,y/x);
else
{
double rt=inf;
for (int i=1;i<=(n>>1);i++)
{
rt=min(rt,max(solve(x*i/n,y,i),solve(x*(n-i)/n,y,n-i)));
rt=min(rt,max(solve(x,y*i/n,i),solve(x,y*(n-i)/n,n-i)));
}
return rt;
}
}
int main()
{
scanf("%d%d%d",&x,&y,&n);
printf("%.6lf\n",solve(x,y,n));
return 0;
}