#46727: C++簡單解


yp11351080@yphs.tp.edu.tw (806-27林晉維)

學校 : 臺北市私立延平高級中學
編號 : 276166
來源 : [203.72.178.1]
最後登入時間 :
2025-09-27 11:38:05

 

#include <iostream>
using namespace std;

int main() {
    int n;
    while (cin >> n) {
        int result = (n * n * n + 5 * n + 6) / 6;
        cout << result << endl;
    }
    return 0;
}

數學公式R(n)=(n^3+5n+6)/6