标签:ace ret scanf code scan i++ can win cout
#include <bits/stdc++.h>
using namespace std;
const int N=1e3+10;
int a[N][N],S[N][N];
int main(){
int n,m,q;
scanf("%d%d%d",&n,&m,&q);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
scanf("%d",&a[i][j]);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
S[i][j]=S[i-1][j]+S[i][j-1]-S[i-1][j-1]+a[i][j];
while(q--){
int x1,y1,x2,y2;
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
cout<<S[x2][y2]-S[x1-1][y2]-S[x2][y1-1]+S[x1-1][y1-1]<<endl;
}
return 0;
}
标签:ace ret scanf code scan i++ can win cout
原文地址:https://www.cnblogs.com/wiseXu/p/13390424.html