3 条题解

  • 2
    @ 2023-10-21 20:42:46

    虽然函数题但不想用函数(bool那种)

    #include <bits/stdc++.h> 
    using namespace std;
    int main()
    {
        int n, sum = 0, x = 1, e = 1;
        cin >> n;
        for(int i = 1; i <= n; i++)
        {
            sum += x;
            x += e;
            e++;
        }
        cout << sum;
        return 0;
    }//已AC
    
    • 1
      @ 2024-6-16 20:31:28

      简单的要S ( ̄︶ ̄)↗

      #include <bits/stdc++.h>
      using namespace std;
      const int N = 1e6;
      int main()
      {
          int n,a[N];
          cin >> n;
          a[1] = 1;
          for (int i = 2;i <= N;i++)
          {
              a[i] += a[i - 1] + i - 1;
          }
          long long  sum = 0;
          for (int i = 1;i <= n;i++)
          {
              sum += a[i];
          }
          cout << sum;
          return 0;
      }
      
      • 0
        @ 2023-7-12 21:08:58
        #include <iostream>
        using namespace std;
        int serie(int n)
        {
        	if (n == 1 || n == 2)
        	{
        		return n;
        	}
        	else
        	{
        		return n - 1 + serie(n - 1);
        	}
        }
        int main()
        {
        	int n;
        	cin >> n;
        	int sum = 0;
        	for (int i = 1; i <= n; i++)
        	{
        		sum += serie(i);
        	}
        	cout << sum;
        	return 0;
        }
        
        • 1

        信息

        ID
        145
        时间
        1000ms
        内存
        16MiB
        难度
        1
        标签
        递交数
        66
        已通过
        54
        上传者