题解
2026-03-26 16:36:06
发布于:浙江
4阅读
0回复
0点赞
直接上代码
#include <bits/stdc++.h>
using namespace std;
const int N=1010;
const int M=1010;
int a[N][M],b[N][M];
int main(){
int n,m,q;
cin>>n>>m>>q;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)
cin>>a[i][j];
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)
b[i][j]=b[i][j-1]+a[i][j];
}
while(q--){
int w,x,y,z;
cin>>w>>x>>y>>z;
int sum=0;
for(int i=x;i<=z;i++){
sum += b[i][y]-b[i][w-1];
}
cout<<sum<<endl;
}
}
这里空空如也







有帮助,赞一个