#include <bits/stdc++.h>
using namespace std;
int a[100010],s[100010];
int main()
{
int n;
cin >> n;
for(int i = 1;i <= n;i++)
{
cin >> a[i];
s[i] = s[i - 1] + a[i];
}
int q;
cin >> q;
for(int i = 1;i <= q;i++)
{
int l,r;
cin >> l >> r;
cout << s[r] - s[l - 1] << endl;
}
return 0;
}
P8218 【深进1.例1】求区间和
于 2023-10-24 21:48:00 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)