您的位置:首页 > 其它

【SCOI 2009】生日快乐 DFS

2016-10-30 00:00 232 查看
这是个DFS……简直丧病

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
double dfs(double x,double y,int n)
{
double ans = 1e9;
if(n == 1)
{
if(x < y)
swap(x,y);
return x / y;
}
for(int i = 1;i < n;i ++)
{
ans = min(ans,max(dfs(x/n*i,y,i),dfs(x/n*(n-i),y,n-i)));
ans = min(ans,max(dfs(x,y/n*i,i),dfs(x,y/n*(n-i),n-i)));
}
return ans;
}
double x,y;
int n;
int main()
{
scanf("%lf %lf %d",&x,&y,&n);
printf("%.6lf",dfs(x,y,n));
return 0;
}

挺好的题……记得面积和长度正相关……
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: