原点,(x,y)形成的矩形内的坐标之和为x*(x+1)/2*(y+1)+y*(y+1)/2*(x+1);
#include<iostream> #include<algorithm> #include<string> #include<string.h> #include<cmath> using namespace std; typedef long long ll; int main() { int n, m, b; while (cin >> m >> b) { ll maxx = 0; for (int y = 0; y <=b; y++) { ll x = (b - y) * m; ll cur = x*(1 + x) / 2 * (1 + y) + y*(y + 1) / 2 * (x + 1); maxx = max(cur, maxx); } cout << maxx << endl; } return 0; }