[SCOI2009]生日快乐

经典代码 来自YXC

YMYXC
 1 #include <cstdio>
 2 #include <iostream>
 3 using namespace std;
 4 double t;
 5 int x, y, n;
 6 inline double DFS (double a, double b, int n)
 7 {
 8     double s = 2e18;
 9     if (n == 1)
10         return max (a, b) / min (a, b);
11     for (int i = 1, j = n - 1; i <= j; i ++, j --)
12     {
13         s = min (s, max (DFS (a, t / a * i, i), DFS (a, t / a * j, j)));
14         s = min (s, max (DFS (t / b * i, b, i), DFS (t / b * j, b, j)));
15     }
16     return s;
17 }
18 int main ()
19 {
20     scanf ("%d%d%d", &x, &y, &n);
21     t = double (x) * y / n;
22     printf ("%.6lf", DFS (x, y, n));
23     return 0;
24 }

 

posted @ 2013-02-04 11:06  Moretimes  阅读(207)  评论(0编辑  收藏  举报