int lowbit(int x){
return x&(-x);
}
void change(int i, int val){
while(i<c.size()){
c[i]+=val;
i+=lowbit(i);
}
}
void sum(int n){
int sum=0 ;
while(n>0){
sum+=c[n];
n-=lowbit(n);
}
return sum;
}
参考:https://blog.csdn.net/dreamgchuan/article/details/51173561