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:59
Task:Algorithm
Sender:Ace of Spades
Submission time:2017-05-27 11:15:59
Status:READY
Result:ACCEPTED

Show test data

Code

#include<iostream>

using namespace std;

int main(void) 
{
    int64_t n;
    cin >> n;

    int64_t res = 0;
    for (int64_t a = 1; a <= n; ++a) {
	res += n*(n+1)/2 - a*(a-1)/2 - (n-a+1)*(a - 1);
    }
    cout << res << '\n';

    return 0;

}