fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long int ll;
  4. typedef pair<ll, ll> ii;
  5.  
  6. const int N = 1e5 + 10;
  7. ll sum[N];
  8.  
  9. void build () {
  10. sum[0] = 0;
  11. for (ll i = 1; i < N; ++i)
  12. sum[i] = sum[i-1] + i;
  13. }
  14.  
  15. int main () {
  16. // build();
  17. ll ans = 0;
  18. ll m, b; scanf("%lld %lld", &m, &b);
  19. for (ll x = 0; ; ++x) {
  20. ll y = b - x;
  21. // printf("x = %lld, y = %lld\n", x, y);
  22. if (y < 0)
  23. break;
  24. ll current = 0;
  25. for (ll i = 0; i <= x; ++i) {
  26. for (ll j = 0; j <= y; ++j)
  27. current += (i + j);
  28. }
  29. ans = max(ans, current);
  30. }
  31. printf("%lld\n", ans);
  32. return 0;
  33. }
Success #stdin #stdout 0s 16840KB
stdin
1 5
stdout
30