3 条题解

  • 0
    @ 2024-10-20 10:09:28
    a=int(input())
    b=1
    c=1
    for j in range(2,a+1):
        for i in range(2,j+1):
            c*=i
        b+=c
        c=1
    print(b)
    

    Python

    • 0
      @ 2023-6-2 11:20:07

      Python

      人生苦短,我用Py

      n = int(input())
      
      ans = 0
      
      while n > 0:
          x = n
          res = 1
          while x > 0:
              res *= x
              x -= 1
          ans += res
          n -= 1
      
      print(ans)
      
      • -3
        @ 2023-7-31 15:35:27

        C++

        依旧朴实无华

        #include<bits/stdc++.h>
        #include<string>
        using namespace std;
        
        int a[10000];
        int b[10000];
        int c[10000];
        int ans[10000];
        
        int main()
        {
        
            int o;
            cin >>o;
            int la,lb,lc;
            ans[1]=1;
            if(o==1){cout<<"1";}
            else{
                for(int po=2; po<=o; po++){
                    for(int i=2; i<=po; i++){
                        if(i==2){
                            la=1;
                            a[1]=1;
                        }
                        else{
                            la=lc;
                        }
                        lb=0;
                        int k=i;
                        for(int j=1; j>0; j++){
                            lb++;
                            b[j]=k%10;
                            k=k/10;
                            if(k<10 && k!=0){
                                b[j+1]=k;
                                lb++;
                                break;
                            }
                            if(k==0){break;}
                        }
                        lc=lb+la;
                        for(int j=1; j<=la; j++){
                            for(int t=1; t<=lb; t++){
                                c[t+j-1]=a[j]*b[t]+c[t+j-1];
                                c[t+j]=c[t+j]+c[t+j-1]/10;
                                c[t+j-1]=c[t+j-1]%10;
                            }
                        }
                        if(c[lc]==0){lc--;}
                        for(int j=1; j<=lc; j++){
                            a[j]=c[j];
                            c[j]=0;
                        }
                    }
                    for(int i=1; i<=lc; i++){
                        ans[i]=ans[i]+a[i];
                        ans[i+1]=ans[i+1]+ans[i]/10;
                        ans[i]=ans[i]%10;
                        a[i]=0;//归零
                        b[i]=0;
                        c[i]=0;
                    }
                }
                if(ans[lc+1]!=0){lc++;}
                for(int i=lc; i>=1; i--){
                    cout<<ans[i];
                }
            }
        
        	return 0;
        }
        
        • 1

        信息

        ID
        284
        时间
        1000ms
        内存
        128MiB
        难度
        5
        标签
        递交数
        20
        已通过
        15
        上传者