当前位置:网站首页>子矩阵的和
子矩阵的和
2022-07-07 23:33:00 【三三木木七】
输入一个 n行 m 列的整数矩阵,再输入 q个询问,每个询问包含四个整数 x1,y1,x2,y2表示一个子矩阵的左上角坐标和右下角坐标。
对于每个询问输出子矩阵中所有数的和。
理解:
代码描述:
代码:
#include<iostream>
using namespace std;
const int N=1010;
int n,m,q;
int a[N][N],s[N][N];
int main()
{
cin>>n>>m>>q;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cin>>a[i][j];
s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+a[i][j];
}
}
//查
int x1,y1,x2,y2;
for(int i=0;i<q;i++)
{
cin>>x1>>y1>>x2>>y2;
cout<<(s[x2][y2]-s[x2][y1-1]-s[x1-1][y2]+s[x1-1][y1-1])<<endl;
}
}
边栏推荐
- 2022 new examination questions for crane driver (limited to bridge crane) and question bank for crane driver (limited to bridge crane) operation examination
- Generic configuration legend
- Gnuradio transmits video and displays it in real time using VLC
- Capstone/cs5210 chip | cs5210 design scheme | cs5210 design data
- Connect to the previous chapter of the circuit to improve the material draft
- HDMI to VGA acquisition HD adapter scheme | HDMI to VGA 1080p audio and video converter scheme | cs5210 scheme design explanation
- npm 內部拆分模塊
- USB type-C docking design | design USB type-C docking scheme | USB type-C docking circuit reference
- General configuration title
- Basic realization of line graph
猜你喜欢
Guojingxin center "friendship and righteousness" - the meta universe based on friendship and friendship, and the parallel of "honguniverse"
4、策略學習
2022 free test questions of fusion welding and thermal cutting and summary of fusion welding and thermal cutting examination
break net
Running OFDM in gnuradio_ RX error: gr:: Log: info: packet_ headerparser_ b0 - Detected an invalid packet at item ××
Arm bare metal
Working principle of stm32gpio port
qt--将程序打包--不要安装qt-可以直接运行
Design method and reference circuit of type C to hdmi+ PD + BB + usb3.1 hub (rj45/cf/tf/ sd/ multi port usb3.1 type-A) multifunctional expansion dock
2022 low voltage electrician examination content and low voltage electrician simulation examination question bank
随机推荐
npm 内部拆分模块
The combination of relay and led small night light realizes the control of small night light cycle on and off
How does Matplotlib generate multiple pictures in turn & only save these pictures without displaying them in the compiler
Ag9310 design USB type C to hdmi+u2+5v slow charging scheme design | ag9310 expansion dock scheme circuit | type-C dongle design data
qt-使用自带的应用框架建立--hello world--使用min GW 32bit
COMSOL - Construction of micro resistance beam model - final temperature distribution and deformation - establishment of geometric model
After modifying the background of jupyter notebook and adding jupyterthemes, enter 'JT -l' and the error 'JT' is not an internal or external command, nor a runnable program
Continued from the previous design
Solve the error: NPM warn config global ` --global`, `--local` are deprecated Use `--location=global` instead.
QT build with built-in application framework -- Hello World -- use min GW 32bit
AttributeError: ‘str‘ object has no attribute ‘strftime‘
General configuration tooltip
5、离散控制与连续控制
EDP to LVDS conversion design circuit | EDP to LVDS adapter board circuit | capstone/cs5211 chip circuit schematic reference
Parade ps8625 | replace ps8625 | EDP to LVDS screen adapter or screen drive board
2021 Shanghai safety officer C certificate examination registration and analysis of Shanghai safety officer C certificate search
4. Strategic Learning
On the concept and application of filtering in radar signal processing
Measure the voltage with analog input (taking Arduino as an example, the range is about 1KV)
2、TD+Learning