写这道题的原因是。。。它太坑了吧
以为好难,二分答案,验证,dp,贼麻烦
结果。。。。D!F!S!
#include <bits/stdc++.h> using namespace std; #define ll long long #define inf 1e9 double dfs(double x,double y,int cnt){ if(cnt==1)return max(x/y,y/x); double maxn=inf; for(int i=1;i<=cnt>>1;i++){ maxn=min(maxn,max(dfs(x/cnt*i,y,i),dfs(x/cnt*(cnt-i),y,cnt-i))); maxn=min(maxn,max(dfs(x,y/cnt*i,i),dfs(x,y/cnt*(cnt-i),cnt-i))); } return maxn; } int main() { double x,y;int n; cin>>x>>y>>n; printf("%.6lf",dfs(x,y,n)); return 0; }