1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| #include <iostream> #include <cstdio> using namespace std; int X, Y, N; double max_rate = 0.0; double min_rate = 1.0e9;
double solve(double x, double y, int n) { if(n == 1) { if(x < y) { swap(x, y); } return x / y; } double max_size = 1.0e9; for(int i = 1; i <= (n >> 1); i++) { double upper = y / n * i; double temp1 = max(solve(x, upper, i), solve(x, y - upper, n - i));
double left = x / n * i; double temp2 = max(solve(left, y, i), solve(x - left, y, n - i)); max_size = min(max_size, min(temp1, temp2)); } return max_size; }
int main() { while(scanf("%d%d%d", &X, &Y, &N) != EOF) { double res = solve((double)X, (double)Y, N); printf("%.6f\n", res); } }
|