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:17:14
Task:Algorithm
Sender:Kanadan virallinen maajoukkue
Submission time:2017-05-27 11:17:14
Status:READY
Result:ACCEPTED

Show test data

Code

#include<iostream>

using namespace std;

long long ret[1000001];

int main(){
    int n;
    cin>>n;
    ret[1] = 1;
    
    for(long long i=2; i<=n; i++)
        ret[i] = ret[i-1] + ((i+1)*(i))/2;
    cout << ret[n] << endl;
    return 0;
}