Sunday, July 13, 2014

Codeforces Round #164 (Div. 2), problem: (B) Buttons solution

Codeforces Round #164 (Div. 2), problem: (B) Buttons: http://codeforces.com/problemset/problem/268/B

Codeforces Round #164 (Div. 2), problem: (B) Buttons editorial: http://codeforces.com/blog/entry/6545?locale=en

Codeforces Round #164 (Div. 2), problem: (B) Buttons solution: http://ideone.com/Kkzz3Q


#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
    long long int n, cnt=0, i=0;
    scanf("%I64d", &n);
    while(n>0) {
        cnt+=n+(n-1)*i;
        n--, i++;
    }
    printf("%I64d", cnt);
    return 0;
}


No comments:

Post a Comment