BZOJ 1024 SCOI2009 生日快乐 暴搜

思路:eng。。。按照题意搜就好了 (一定要注意题面的n<=10……)
枚举断点。。。反正n<=10不怂

//By SiriusRen
#include <cstdio>
#include <algorithm>
using namespace std;
int n,m,k;
double ans=0x3fffffff,area;
double dfs(double x,double y,int remain){
    if(remain==1)return max(x/y,y/x);
    double temp=0x3fffffff;
    for(int i=1;i<=remain/2;i++){
        double ty=area*i/x,tx=area*(remain-i)/y;
        temp=min(temp,min(max(dfs(x-tx,y,i),dfs(tx,y,remain-i)),max(dfs(x,y-ty,remain-i),dfs(x,ty,i))));
    }
    return temp;
}
int main(){
    scanf("%d%d%d",&n,&m,&k);
    area=1.0*n*m/k;
    printf("%.6lf\n",dfs(1.0*n,1.0*m,k));
}

列表内容

posted @ 2016-09-14 23:58  SiriusRen  阅读(80)  评论(0编辑  收藏