Advertisement
kadeyrov

Untitled

Oct 4th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. //
  2. //  main.cpp
  3. //  AndeyLess
  4. //
  5. //  Created by Kadir Kadyrov on 08.07.2020.
  6. //  Copyright © 2020 Kadir Kadyrov. All rights reserved.
  7. //
  8.  
  9. #include <iostream>
  10. #include <vector>
  11. #include <queue>
  12. #include <algorithm>
  13.  
  14. using namespace std;
  15.  
  16. //int main () {
  17. //    int k, w, n;
  18. //    cin >> k >> n >> w;
  19. //
  20. //    long long ans = (k * w * (w + 1)) / 2;
  21. //
  22. //    if (ans > n) {
  23. //        cout << ans - n << endl;
  24. //    } else {
  25. //        cout << 0 << endl;
  26. //    }
  27. //}
  28.  
  29. int main () {
  30.     int k, n, w;
  31.     cin >> k >> n >> w;
  32.     int ans = 0;
  33.     for (int i = 1; i <= w; i++) {
  34.         ans  += i * k;
  35.     }
  36.     if (ans > n) {
  37.         cout << ans - n << endl;
  38.     } else {
  39.         cout << 0 << endl;
  40.     }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement