传送门
题解:定义状态dfs(x,y,res)表示长宽/宽长为x,y且还有res个人没分到时的答案,直接暴搜。多写写搜索吧,NOIP再难也逃不过一句话:骗分过样例,暴力出奇迹!
#include<bits/stdc++.h>
using namespace std;
double x,y;
int cnt;
double dfs(double x,double y,int res) {//edge 1,edge 2,how many people left
if (res==1) return max(x/y,y/x);
double ans=1e9;
for (int i=1;i<=(res>>1);++i) {
ans=min(ans,max(dfs(x,y*i/res,i),dfs(x,y*(res-i)/res,res-i)));
ans=min(ans,max(dfs(x*i/res,y,i),dfs(x*(res-i)/res,y,res-i)));
}
return ans;
}
int main() {
scanf("%lf%lf%d",&x,&y,&cnt);
printf("%.6lf\n",dfs(x,y,cnt));
return 0;
}