搜索等分点,看在哪部分找就行了
代码
//By AcerMo
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const double M=1e9+7;
int n;
double a,b;
double minn(double x,double y)
{if (x<y) return x;else return y;
}
double dfs(double x,double y,int cnt)
{if (x<y) swap(x,y);if (cnt==1) return x/y;double ans=M;for (int i=1;i<=cnt/2;i++){ans=minn(ans,max(dfs(x*i/cnt,y,i),dfs(x*(cnt-i)/cnt,y,cnt-i)));ans=minn(ans,max(dfs(x,y*i/cnt,i),dfs(x,y*(cnt-i)/cnt,cnt-i)));}return ans;
}
signed main()
{cin>>a>>b>>n;double ans=M;if (a<b) swap(a,b);if (n==1) return printf("%.6lf",a/b),0;for (int i=1;i<=n/2;i++){ans=minn(ans,max(dfs(a*i/n,b,i),dfs(a*(n-i)/n,b,n-i)));ans=minn(ans,max(dfs(a,b*i/n,i),dfs(a,b*(n-i)/n,n-i)));}printf("%.6lf",ans);return 0;
}