题解

3 条题解

  • 1
    @ 2023-07-14 17:18:05
    #include<cmath>
    #include<cstdio>
    #include<cctype>
    #include<cstdlib>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    #define N 110
    #define R register
    using namespace std;
    
    int n,q;
    double g[N],f[N][N];
    
    int main(){
      scanf("%d%d",&q,&n);
      if(q==1){
        g[1]=0.0;
        for(R int i=2;i<=n;++i) g[i]=g[i-1]+2.0/i;
        printf("%.6lf",g[n]);
      }
      else{
        for(R int i=1;i<=n;++i) f[i][0]=1.0;
        for(R int i=2;i<=n;++i)
          for(R int j=1;j<i;++j){
            for(R int k=1;k<i;++k)
              f[i][j]+=f[k][j-1]+f[i-k][j-1]-f[k][j-1]*f[i-k][j-1];
            f[i][j]/=(i-1);
          }
        double ans=0.0;
        for(R int i=1;i<=n;++i) ans+=f[n][i];
        printf("%.6lf\n",ans);
      }
      return 0;
    }
    
    
    
    
  • 1
    @ 2017-03-31 11:22:58
  • 0
    @ 2021-12-19 15:53:48
    #include<cmath>
    #include<cstdio>
    #include<cctype>
    #include<cstdlib>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    #define N 110
    #define R register
    using namespace std;
    
    int n,q;
    double g[N],f[N][N];
    
    int main(){
      scanf("%d%d",&q,&n);
      if(q==1){
        g[1]=0.0;
        for(R int i=2;i<=n;++i) g[i]=g[i-1]+2.0/i;
        printf("%.6lf",g[n]);
      }
      else{
        for(R int i=1;i<=n;++i) f[i][0]=1.0;
        for(R int i=2;i<=n;++i)
          for(R int j=1;j<i;++j){
            for(R int k=1;k<i;++k)
              f[i][j]+=f[k][j-1]+f[i-k][j-1]-f[k][j-1]*f[i-k][j-1];
            f[i][j]/=(i-1);
          }
        double ans=0.0;
        for(R int i=1;i<=n;++i) ans+=f[n][i];
        printf("%.6lf\n",ans);
      }
      return 0;
    }
    
    
    

    \(\color{#ad8b00}\texttt{I\ AK\ SSH}\)

  • 1

信息

ID
1984
难度
3
分类
(无)
标签
递交数
59
已通过
32
通过率
54%
被复制
2
上传者