原题链接
题解
#include "iostream"
#include "vector"
using namespace std;
int main(){
int n,m,tmp,l,r;
cin>>n>>m;
vector<int>num;
num.push_back(0);
for(int i=1;i<=n;i++){
cin>>tmp;
num.push_back(tmp);
if(i!=1){
num[i]+=num[i-1];
}
}
for(int i=0;i<m;i++){
cin>>l>>r;
cout<<num[r]-num[l-1]<<endl;
}
}
标签:tmp,前缀,int,练习,back,num,push,include,acwing
From: https://www.cnblogs.com/ChengMao/p/17114129.html