zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    hph 缓存机制
    递归调用 和 迭代
    多维数组排序
    php curl操作
    JavaScript基本数据类型
    JavaScript基础
    CSS基础布局
    CSS基础样式
    CSS选择器
    CSS3基础
  • 原文地址:https://www.cnblogs.com/proverbs/p/2945071.html
Copyright © 2011-2022 走看看