树状数组模板

int modify(int x,int num){while(x<=n)c[x]+=num,x+=x&-x;}
int query(int x){int s=0;while(x>0)s+=c[x],x-=x&-x;return s;}

愿你出走半生,归来仍是少年

原文地址:https://www.cnblogs.com/forever97/p/3450006.html