BZOJ 1024 [SCOI2009]生日快乐

十分神奇的题。想了二分又想怎么贪心,然后。。其实它就是个暴力呀。。

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
typedef long long LL;
using namespace std;
double x,y,k;
double solve(double x,double y,double k) {
    if(k==1) return (max(x,y)/min(x,y)); 
    double res=1e9;
    for(int i=1;i<k;i++) 
        res=min(res,max(solve(x/k*i,y,i),solve(x/k*(k-i),y,k-i)));
    for(int i=1;i<k;i++) 
        res=min(res,max(solve(x,y/k*i,i),solve(x,y/k*(k-i),k-i)));
    return res;
}
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    scanf("%lf%lf%lf",&x,&y,&k);
    printf("%.6lf\n",solve(x,y,k));
    return 0;
}
View Code

 

posted @ 2017-09-18 21:09  啊宸  阅读(92)  评论(0编辑  收藏