fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int k,n,w;
  6. cin >> k >> n >> w;
  7. int totalrequired = 0;
  8. for(int i =1;i<=w;i++){
  9. totalrequired+= i*k;
  10. }
  11. cout << totalrequired - n << endl;
  12.  
  13. return 0;
  14. }
Success #stdin #stdout 0s 5304KB
stdin
3 17 4
stdout
13