int ask(int x){
int ans=0;
for(;x;x-=x&-x) ans+=c[x];
return ans;
}
void add(int x,int y){
for(;x<=N;x+=x&-x) c[x]+=y;
}
【模板】 树状数组
最新推荐文章于 2023-04-13 21:15:37 发布
int ask(int x){
int ans=0;
for(;x;x-=x&-x) ans+=c[x];
return ans;
}
void add(int x,int y){
for(;x<=N;x+=x&-x) c[x]+=y;
}