17 条题解

  • 1
    @ 2024-10-13 18:58:10
    • #include using namespace std; int main(){ int n; cin>>n; int ans=1; int sum=0; for(int i=1;i<=n;i++) { ans*=i; sum+=ans; } cout<<sum; }
    • 1
      @ 2023-6-2 19:11:29

      兄弟们,为什么ans和sum不能开long long,int就行?大佬求解 longlong代码:(错的,不要复制)

      #include <iostream>
      #include <bits/stdc++.h>
      using namespace std;
      const int N=1e7+10;
      const int INF=0x3f3f3f3f;
      int main()
      {
      int n;
      long long sum=1,ans;
      cin>>n;
      for(int i=1;i<=n;i++)
      {
      for(int j=1;j<=i;j++)
      {
      sum*=j;
      }
      ans+=sum;
      sum=1;
      }
      cout<<ans;
      }
      
      

      int代码:

      #include <iostream>
      #include <bits/stdc++.h>
      using namespace std;
      const int N=1e7+10;
      const int INF=0x3f3f3f3f;
      int main()
      {
      	int n;
      	int sum=1,ans;
      	cin>>n;
      	for(int i=1;i<=n;i++)
      	{
      		for(int j=1;j<=i;j++)
      		{
      			sum*=j;
      		}
      		ans+=sum;
      		sum=1;
      	} 
      	cout<<ans;
      }
      
      
      • 0
        @ 2025-8-30 17:17:45

        #include <bits/stdc++.h> using namespace std;

        long long f(int a){ long long ans = 1; for(int i = 1;i <= a;i++) ans *= i; return ans; } int main(){ cin.tie(0); cout.tie(0); int n,sum = 0; cin>>n; for(int i = 1;i <= n;i++){ sum += f(i); } cout<<sum; return 0; }

        • 0
          @ 2025-8-30 17:17:34

          #include <bits/stdc++.h> using namespace std;

          long long f(int a){ long long ans = 1; for(int i = 1;i <= a;i++) ans *= i; return ans; } int main(){ cin.tie(0); cout.tie(0); int n,sum = 0; cin>>n; for(int i = 1;i <= n;i++){ sum += f(i); } cout<<sum; return 0; }

          • 0
            @ 2024-10-13 18:57:19

            #include using namespace std; int main(){ int n; cin>>n; int ans=1; int sum=0; for(int i=1;i<=n;i++) { ans*=i; sum+=ans; } cout<<sum; }

            • 0
              @ 2023-4-12 20:03:16

              #include using namespace std; int n,ans,jc=1; int main(){

              cin >> n;
              for(int i = 1;i <= n;i++)
              { 
               	jc = 1; 
               	for(int j = 1;j <=i;j++)
                  {
                  	jc*=j;
              	}
              	ans +=jc;
              }
              cout<<ans;
              return 0;
              

              }

              • 0
                @ 2023-4-12 20:02:19
                using namespace std;
                int main()
                {
                    int n;
                    cin >> n;
                    int ans = 1;
                    int jc=0 ;
                    for (int i = 1; i <= n; i++)
                    {
                        ans *=i;
                        jc += ans;
                    }
                    cout << jc;
                }
                
                
                • 0
                  @ 2023-4-1 12:20:41

                  #include #include using namespace std; int main() { int n,sum=0,m=1; cin>>n; for(int i=1; i<=n; i++)//常用i,j,k { m*=i; sum+=m; } cout<<sum; return 0; }

                  • -1
                    @ 2024-3-11 21:11:15
                    #include <iostream>
                    #include <stdio.h>
                    #include <math.h>
                    #include <iomanip>
                    using namespace std;
                    int m , n , ans; 
                    int main()
                    {
                    	cin >> m >> n;
                    	for( int i = m ; i <= n ; i++ )
                    	{
                    		if( i % 17 == 0 )
                    		{
                    			ans += i;
                    		}
                    	}
                    	cout << ans;
                        return 0;
                    }
                    
                    • -4
                      @ 2024-10-13 18:09:19

                      #include <stdio.h> #include using namespace std; int main() { int n; cin>>n; int ans =1; int sum =0; for(int i = 1 ; i <= n ; i++) { ans *=i; sum += ans; } cout<< sum << endl; }

                      • -4
                        @ 2022-4-17 17:32:39
                        #include <stdio.h>
                        #include <iostream>
                        using namespace std;
                        int main()
                        {
                            int n;
                            cin >> n;
                            int ans = 1;
                            int sum = 0;
                            for (int i = 1; i <= n; i++)
                            {
                                ans *=i;
                                sum += ans;
                            }
                            cout << sum << endl;
                        }
                        
                        • -5
                          @ 2023-1-3 13:05:47
                          #include<bits/stdc++.h>
                          using namespace std;
                          int n;
                          long long jc(int n)
                          {
                          	if(n==1)return 1;
                          	long long sum=1;
                          	for(int i=2;i<=n;i++)sum*=i;
                          	sum+=jc(n-1);
                          	return sum;
                          }
                          int main()
                          {
                          	cin>>n;
                          	long long ans=jc(n);
                          	cout<<ans;
                          	return 0;
                          }
                          
                          • -6
                            @ 2022-1-8 11:54:13
                            #include <iostream>
                            #include <math.h>
                            #include <iomanip>
                            using namespace std;
                            #define LL Long Long
                            const int N=1e5+10;
                            const int INF=0x3f3f3f3f;
                            int main()
                            {
                            	int n;
                            	cin >> n;
                            	int ans = 1;
                            	int sum = 0;
                            	for(int i = 1 ; i <= n ; i++)
                            	{
                            		ans *= i;
                            		sum += ans;
                            	}
                            	cout << sum << endl;
                            }
                            
                            • -7
                              @ 2022-1-8 11:54:10
                              #include <stdio.h>
                              #include <iostream>
                              #include <math.h>
                              using namespace std;
                              int main()
                              {
                              	int n;
                              	cin>>n;
                              	int ans=1;
                              	int sum=0;
                              	for(int i=1;i<=n;i++)
                              	{
                              		ans*=i;
                              		sum+=ans;
                              	}
                              	cout<<sum;
                              }
                              
                              • -8
                                @ 2022-1-8 15:39:38

                                打表义不容辞

                                #include<iostream> 
                                using namespace std; 
                                int n[13] = {0,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600};
                                int k, sum;
                                int main(){
                                    cin >> k;
                                	for(int i = 1; i <= k; i++){
                                        sum += n[i];
                                    }
                                    cout << sum;
                                    return 0;
                                }
                                
                                • -10
                                  @ 2022-1-8 11:56:03
                                  #include <stdio.h>
                                  #include <iostream>
                                  using namespace std;
                                  int main()
                                  {
                                  	int n;
                                  	cin >> n;
                                  	int ans = 1;
                                  	int sum = 0;
                                  	for(int i = 1 ; i <= n ; i++)
                                  	{
                                  		ans *= i;
                                  		sum += ans;
                                  	}
                                  	cout << sum << endl;
                                  }
                                  
                                  • -10
                                    @ 2022-1-8 11:53:19
                                    #include <stdio.h>
                                    #include <iostream>
                                    using namespace std;
                                    int main()
                                    {
                                        int n;
                                        cin >> n;
                                        int ans = 1;
                                        int sum = 0;
                                        for (int i = 1; i <= n; i++)
                                        {
                                            ans *=i;
                                            sum += ans;
                                        }
                                        cout << sum << endl;
                                    }
                                    
                                    • 1

                                    信息

                                    ID
                                    932
                                    时间
                                    1000ms
                                    内存
                                    128MiB
                                    难度
                                    4
                                    标签
                                    递交数
                                    880
                                    已通过
                                    396
                                    上传者