bzoj1024 [SCOI2009]生日快乐【dfs】

传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1024

普通的深搜。

#include <cstdio>
#include <algorithm> int xx, yy, n; double slove(double x, double y, int left) {
if (left == 1) {
return x > y? x / y: y / x;
}
double rt = 1.0e100, tx = x / left, ty = y / left;
for (int i = 1; i <= (left >> 1); ++i) {
rt = std::min(rt, std::max(slove(tx * i, y, i), slove(tx * (left - i), y, left - i)));
rt = std::min(rt, std::max(slove(x, ty * i, i), slove(x, ty * (left - i), left - i)));
}
return rt;
} int main(void) {
scanf("%d%d%d", &xx, &yy, &n);
printf("%.6f\n", slove((double)xx, (double)yy, n));
return 0;
}

  

上一篇:Linux学习的第四天


下一篇:【bzoj1024】[SCOI2009]生日快乐