https://www.acwing.com/problem/content/797/
思路前缀和板子,我们通过 p r e [ i ] = p r e [ i − 1 ] + a [ i ] pre[i] = pre[i-1] + a[i] pre[i]=pre[i−1]+a[i]能维护a的前缀和
#include
using namespace std;
#define ll long long
#define mod 1000000009
#define endl "\n"
#define PII pair
ll ksm(ll a,ll b) {
ll ans = 1;
for(;b;b>>=1LL) {
if(b & 1) ans = ans * a % mod;
a = a * a % mod;
}
return ans;
}
ll lowbit(ll x){return -x & x;}
const int N = 2e6+10;
ll n,m,a[N];
int main()
{
cin>>n>>m;
for(int i = 1;i >a[i];
a[i] += a[i-1];
}
int l,r;
while(m--) {
cin>>l>>r;
cout
关注
打赏