题解:
这道题我看的是别人的解释,
https://www.cnblogs.com/shingen/p/7105280.html
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define LL long long
int main()
{
LL m,b;
while(~scanf("%lld%lld",&m,&b))
{
LL sum=0,ans=0;
for(int y=0;y<=b;y++)
{
LL x=(b-y)*m;
LL sum= x*(1+x)/2*(1+y)+y*(1+y)/2*(1+x);
//等差数列求和公式推导
ans=max(sum,ans);
}
printf("%lld\n",ans);
}
}
本文介绍了一个使用C++编写的程序,该程序通过遍历所有可能的坐标(x,y)来寻找最大的数值表达式结果。利用等差数列求和公式进行计算优化,并通过不断更新最大值来获取最终答案。
132

被折叠的 条评论
为什么被折叠?



