BZOJ 1024 搜索

题解:

一开始想二分答案,发现不会验证。。

然后果断看到题解说每一刀切在哪里是可以算的。。按照两边的分配的块数。。

暴力就好~

 

 

View Code
 1 #include <iostream>
 2 #include <cstring>
 3 #include <cstdlib> 
 4 #include <cstdio>
 5 #include <algorithm>
 6 
 7 #define INF 1e9
 8 
 9 using namespace std;
10 
11 int n,m,gs;
12 
13 inline double dfs(double x,double y,int cnt)
14 {
15     if(cnt==1) return max(x/y,y/x);
16     double rt=INF;
17     for(int i=1;i<=(cnt>>1);i++)
18     {
19         rt=min(rt,max(dfs(x/cnt*i,y,i),dfs(x/cnt*(cnt-i),y,cnt-i)));
20         rt=min(rt,max(dfs(x,y/cnt*i,i),dfs(x,y/cnt*(cnt-i),cnt-i)));
21     }
22     return rt;
23 }
24 
25 inline void go()
26 {
27     scanf("%d%d%d",&n,&m,&gs);
28     double ans=dfs(n,m,gs);
29     printf("%.6lf\n",ans);
30 }
31 
32 int main()
33 {
34     go();
35     return 0;
36 }

 

 

posted @ 2013-03-05 21:14  proverbs  阅读(892)  评论(0编辑  收藏  举报