Skip to content

Instantly share code, notes, and snippets.

@surinoel
Created July 25, 2019 23:34
Show Gist options
  • Select an option

  • Save surinoel/e914576faf14aed8b8610b37f58d514e to your computer and use it in GitHub Desktop.

Select an option

Save surinoel/e914576faf14aed8b8610b37f58d514e to your computer and use it in GitHub Desktop.
#include <vector>
#include <iostream>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
long long n;
cin >> n;
long long sum = 0;
for (int i = 1; i < n; i++) {
sum += i * n + i;
}
cout << sum << '\n';
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment