Code for USACO practice problems
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.
 
 

17 lines
293 B

#include <iostream>
using namespace std;
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;
}