能解决什么问题
动态求连续区间和
时间复杂度
O(log n)
代码
int tr[N];
int lowbit(int x)
{
return x & -x;
}
void add(int x, int v)
{
for (int i = x; i < N; i += lowbit(i)) tr[i] += v;
}
void query(int x)
{
int res = 0;
for (int i = x; i > 0; i -= lowbit(i)) res += tr[i];
return res;
}
标签:return,树状,int,lowbit,void,tr,数组,res
From: https://www.cnblogs.com/cong0221/p/17120775.html