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;
}

  

posted @ 2017-02-09 13:06  ciao_sora  阅读(123)  评论(0编辑  收藏