7546 金币数量

#include<bits/stdc++.h>
#define f(i,s,e) for(int i = s; i <= e; i++)
#define ll long long
using namespace std;
const int N = 1e3+10,inf = 0x3f3f3f3f;

int main()
{
    int n,sum = 0,g = 0;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        g += i; //金币每层都会加i
        sum += g; //累加金币 
    }
    cout << sum;
    return 0;
}

 

posted @ 2024-06-30 22:48  CRt0729  阅读(39)  评论(0编辑  收藏  举报