2 条题解

  • 1
    @ 2025-1-23 15:56:14

    用递归算法即可

    #include<bits/stdc++.h>
    using namespace std;
    
    long long fun(int x){
    	if (x==1) return 1;
    	return x*fun(x-1);	
    }
    
    int main(){
    	int n;
    	cin>>n;
    	cout<<fun(n);
    	return 0;
    }
    
    • 0
      @ 2025-8-4 14:43:47
      #include <bits/stdc++.h>
      using namespace std;
      int main()
      {
          long long  n;
          cin>>n;
          long long result = 1;
          for(int i=1;i<=n;i++)
          {
              result*=i;
          }
          cout<<result;
      }
      ```
      
      
      ```
      • @ 2025-8-4 14:45:13

        可以不用地龟,写个循环,开个long long 就行了。(最好还是按照题目要求写地龟)

    • 1

    信息

    ID
    140
    时间
    1000ms
    内存
    256MiB
    难度
    3
    标签
    递交数
    54
    已通过
    31
    上传者