题意:告诉你一条直线y , 让你求y上的某一点,使得过该点向x,y轴做垂线后得到的矩形和最大。和的定义是矩阵内每个点的 横坐标+纵坐标 ;
思路:穷举x,得到和的规律就好
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
ll m,b;
cin >> m>>b;
ll maxs=-LONG_LONG_MIN;
for(ll x=1;x<=m*b;x++)
{
ll y=-x/m+b;
if(m*y!=-x+m*b) continue;
ll sum=(0+x)*(x+1)/2;
ll sum1=sum*(y+1)+(0+y)*(y+1)/2*(x+1);
//printf("x=%I64d sum1=%I64d\n",x,sum1);
maxs=max(maxs,sum1);
}
cout << maxs << endl;
}