树状数组
1.求lowbit
int lowbit(int x) {return x & -x;}
2.更新(pudate)
void _Update(int index, int x) {
for(int i = index; i <= n; i += _Lowbit(i))
BIT[i] += x;
return;
}
3.求前缀和
int _Sum(int x) {
int sum = 0;
for(int i = x; i > 0; i -= _Lowbit(i))
sum += BIT[i];
return sum;
}
转载请注明原文地址:https://blackberry.8miu.com/read-34051.html