Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define pb push_back
- #define L long long
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(0);
- //freopen("input.txt", "r", stdin);
- //freopen("output.txt", "w", stdout);
- long double m,b;
- cin >> m >> b;
- long double x = 0, y = b;
- long long ans = 0;
- while (y >= 0) {
- L cur = 0, add = 0, yy = (int) y;
- if (x!=0 && y!=0) {
- cur=(yy + 1) * ((x + 1) * x / 2) + (x + 1) * ((yy + 1) * yy / 2);
- ans = max(ans, cur);
- }
- if (x==0 && y==0) {
- x++;
- y = -(x/m) + b;
- continue;
- }
- if (x == 0) {
- L d=(x + 1) * ((yy + 1) * yy / 2);
- ans = max(ans, d);
- } else if (yy == 0) {
- L d=(yy + 1) * ((x + 1) * x / 2);
- ans = max(ans, d);
- }
- x++;
- y = -(x/m) + b;
- }
- cout << ans << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement