码迷,mamicode.com
首页 > Windows程序 > 详细

AcWing 795. 前缀和

时间:2020-07-28 14:26:44      阅读:81      评论:0      收藏:0      [点我收藏+]

标签:mes   include   scanf   前缀和   ret   const   bit   names   scan   

AcWing 795. 前缀和


#include <bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int a[N],S[N];
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) {
        scanf("%d",&a[i]);
        S[i]=S[i-1]+a[i];
    }
    while(m--){
        int l,r;
        scanf("%d%d",&l,&r);
        cout<<S[r]-S[l-1]<<endl;
    }
    return 0;
}

AcWing 795. 前缀和

标签:mes   include   scanf   前缀和   ret   const   bit   names   scan   

原文地址:https://www.cnblogs.com/wiseXu/p/13390421.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!