51Nod 1081前缀和
#include <iostream> #include <stdio.h> using namespace std; long long a[50005]; long long sum[50005]; int main() { int n; cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; sum[i]=sum[i-1]+a[i]; } int q; cin>>q; while(q--) { int x,y; cin>>x>>y; cout<<sum[x+y-1]-sum[x]+a[x] <<endl; } return 0; }