[bzoj1024][SCOI2009]生日快乐【暴力】

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

/* --------------
    user Vanisher
    problem bzoj-1024
----------------*/
# include 
# 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 (xif (k==1) return x/y;
    double ans=inf;
    for (int i=1; ireturn ans;
}
int main(){
    int x=read(), y=read(), n=read();
    printf("%.6lf\n",solve(x,y,n));
    return 0;
}

你可能感兴趣的:(【暴力】)