代码如下:
#include <bits/stdc++.h>
using namespace std;
int n,m;
long long sq,rec;
int x,y,s,t,p;
int main()
{
scanf("%d %d",&n,&m);
n++,m++;
for(x=0;x<n-1;x++)
{
for(y=0;y<m-1;y++)
{
s=(n-1-x)*(m-1-y);
t=min(n-1-x,m-1-y);
sq+=t;
rec+=s-t;
}
}
printf("%ld %ld",sq,rec);
return 0;
}
第4、5、6、7、8、9个数据点WA,其中第四个数据点输入为:
400 400
,正确输出为:
21413400 6410626600
我的输出为:
21413400 2115659304