Code for USACO practice problems
cpp
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

18 lines
294 B

using namespace std;
#include <iostream>
int main() {
int k, n, total_cost;
total_cost = 0;
long w;
cin >> k >> n >> w;
for (int i = 1; i < w + 1; i++) {
total_cost += i * k;
}
total_cost -= n;
if (total_cost < 0) {
total_cost = 0;
}
cout << total_cost << endl;
}