#include<bits/stdc++.h>
using namespace std;
int n, m;
int a[100010];
long long per_sum[100010];
int l, r;
int main()
{
cin>>n>>m;
for(int i=1; i<=n; i++)cin>>a[i];
for(int i=1; i<=n; i++)per_sum[i]=per_sum[i-1]+a[i];//前缀和预处理
while(m--){
cin>>l>>r;
cout<<per_sum[r]-per_sum[l-1]<<endl;
}
return 0;
}
标签:前缀,int,long,一维,例题,100010
From: https://www.cnblogs.com/tflsnoi/p/17111028.html