ProgMe

Task A

Dec 16th, 2020 (edited)
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.20 KB | None | 0 0
  1. #include <iostream>
  2. #define int int64_t
  3.  
  4. using namespace std;
  5.  
  6. int32_t main()
  7. {
  8. int n, a, d, m;
  9. cin >> n >> a >> d >> m;
  10. cout << max((int)0, (int)(2 * a + d * (n - 1)) * n / 2 - m);
  11. }
Add Comment
Please, Sign In to add comment