zoukankan      html  css  js  c++  java
  • [bzoj1024][SCOI2009]生日快乐【暴力】

    【题目链接】
      http://www.lydsy.com/JudgeOnline/problem.php?id=1024
    【题解】
      暴力每一刀是横着切还是竖着切并枚举两侧的块数。
      复杂度分析:
        设 g[i]n=i 时的复杂度。
        于是有:
         g[i]=1 (i=1)
         g[i]=2j=1i1(g[j]+g[ij])+1 (i2)
         整理后得 g[i]=5i1
      所以复杂度为 O(5n)

    /* --------------
        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
    ",solve(x,y,n));
        return 0;
    }
    
  • 相关阅读:
    MySQL数据库生成某一年的日历存储过程
    MySQL随笔(四)
    MySQL索引
    MySQL随笔(三)
    MySQL随笔(二)
    MySQL随笔(一)
    设计模式---策略模式
    数组间相互转换 int[]转list
    安装brew -- Homebrew
    mongodb查询方法
  • 原文地址:https://www.cnblogs.com/Vanisher/p/9135999.html
Copyright © 2011-2022 走看看