fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5. typedef pair<int, int> PII;
  6. typedef vector<int> VI;
  7.  
  8. #define MAXN 200001
  9. #define pb push_back
  10. #define mp make_pair
  11. #define MOD (ll)1e9+7
  12. #define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  13. #define rep(i, a, b) for(int i = a; i < b; ++i)
  14.  
  15. ll m, b;
  16.  
  17. bool check(ll x, ll y) {
  18. double y0 = (double)-x/m + b;
  19. if(y < y0)
  20. return true;
  21. if(abs(y0-y) <= 0.0000000000001)
  22. return true;
  23. return false;
  24. }
  25.  
  26. ll calcc(ll x, ll y) {
  27. return (x*(x+1))/2 * (y+1) + (y*(y+1))/2 * (x+1);
  28. }
  29.  
  30. int main() {
  31. FASTIO
  32. cin >> m >> b;
  33. ll ans = 0;
  34. for(ll i = 1000; i >= 0; --i) {
  35. for(ll j = 10000; j >= 0; --j) {
  36. if(check(i, j)) {
  37. ans = max(ans, calcc(i, j));
  38. }
  39. }
  40. }
  41. cout << ans;
  42. }
Success #stdin #stdout 0s 16064KB
stdin
1 5
stdout
30