基础前缀和
作者:互联网
https://www.acwing.com/problem/content/797/
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<iostream>
using namespace std;
const int N = 1e5+5;
int n,m,l,r;
int a[N],s[N];
int main()
{
cin >> n >> m;
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
s[i]=s[i-1]+a[i];
}
while(m--)
{
scanf("%d%d",&l,&r);
printf("%d\n",s[r]-s[l-1]);
}
return 0;
}
标签:797,std,www,main,前缀,int,基础,include 来源: https://www.cnblogs.com/lxl-233/p/16664555.html