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:12:45
Task:Algorithm
Sender:KnowYourArchitecture
Submission time:2017-05-27 11:12:45
Status:READY
Result:ACCEPTED

Show test data

Code

#include <bits/stdc++.h>

using namespace std;

int main() {
    long long n, z = 0;
    
    cin >> n;
    
    //for (int a = 1; a <= n; a++)
    //    for (int b = a; b <= n; b++)
    //        for (int c = a; c <=b; c++)
    //            z++;
    
    //cout << z << endl;
    
    z = 0;
    
    for (long long a = 1; a <= n; a++)
        z += (1 + n-a +1)*(n-a+1) / 2;
    cout << z << endl;

    return 0;
}