Code Submission Evaluation System Login

CSES - HIIT Open 2017

HIIT Open 2017

Contest start:2017-05-27 11:00:00
Contest end:2017-05-27 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard


History
2017-05-27 11:15:58
Task:Algorithm
Sender:kyy-kol
Submission time:2017-05-27 11:15:58
Status:READY
Result:ACCEPTED

Show test data

Code

#include <iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    long s = 0;
    for (int i = 1; i <= n; ++i) {
        s += long(n-i+1)*long(n-i+2)/2;
    }
    cout << s << endl;
}