[bzoj1024][SCOI2009]生日快乐【暴力】
【题目链接】
http://www.lydsy.com/JudgeOnline/problem.php?id=1024
【题解】
暴力每一刀是横着切还是竖着切并枚举两侧的块数。
复杂度分析:
设 为 时的复杂度。
于是有:
整理后得
所以复杂度为 O()
/* --------------
user Vanisher
problem bzoj-1024
----------------*/
# include <bits/stdc++.h>
# define ll long long
# define inf 0x3f3f3f3f
using namespace std;
int read(){
int tmp=0, fh=1; char ch=getchar();
while (ch<'0'||ch>'9'){if (ch=='-') fh=-1; ch=getchar();}
while (ch>='0'&&ch<='9'){tmp=tmp*10+ch-'0'; ch=getchar();}
return tmp*fh;
}
double solve(double x, double y, int k){
if (x<y) swap(x,y);
if (k==1) return x/y;
double ans=inf;
for (int i=1; i<k; i++){
ans=min(ans,max(solve(x/k*i,y,i),solve(x/k*(k-i),y,k-i)));
ans=min(ans,max(solve(x,y/k*i,i),solve(x,y/k*(k-i),k-i)));
}
return ans;
}
int main(){
int x=read(), y=read(), n=read();
printf("%.6lf\n",solve(x,y,n));
return 0;
}