感受

思路







复杂度分析



#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 100;
double x, y;
int n;
double dfs(double x, double y, int k){
    if(k == 1){
        return max(x, y) / min(x, y);
    }
    double tx, ty; tx = x / k; ty = y / k;
    double ans = 1e15;
    for(int i = 1; i < k; i++){
        ans = min(ans, max(dfs(i * tx, y, i), dfs(x - i * tx, y, k - i)));
        ans = min(ans, max(dfs(x, i * ty, i), dfs(x, y - i * ty, k - i)));
    }
    return ans;
}
int main(){
    scanf("%lf%lf%d", &x, &y, &n);
    printf("%.6f\n", dfs(x, y, n));
    return 0;
}