我大致算了一下他的最大值也就是5005001000=2.5*1e8
不会超啊
不开的话,当时wa了两个点,显示column1读到了负号
cpp
#include
using namespace std;
typedef long long ll;
const int N=510;
ll g[N][N];
ll n,m,k,ans;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m >> k;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
cin >> g[i][j];
g[i][j]+=g[i-1][j]+g[i][j-1]-g[i-1][j-1];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
int x=i,y=j;
while(y<=m&&g[x][y]-g[i-1][y]-g[x][j-1]+g[i-1][j-1]<=k)y++;
ans+=y-j;
for(int a=x+1,b=y-1;a<=n;a++)
{
while(b>=j&&g[a][b]-g[i-1][b]-g[a][j-1]+g[i-1][j-1]>k)b--;
if(b<j)break;
ans+=b-j+1;
}
}
}
cout << ans;
}