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