又是一个debug的下午-->这是树状数组的一个板子
ll getsum(ll x)
{
ll sum1 = 0, sum2 = 0;
for (; x; x -= lowbit(x))
{
sum1 += c[x];
sum2 += b[x];
}
return sum1 + sum2 * x; //x自减了还在使用
}
ll getsum(ll x)
{
ll sum1 = 0, sum2 = 0;
ll y = x;
for (; x; x -= lowbit(x))
{
sum1 += c[x];
sum2 += b[x];
}
return sum1 + sum2 * y;
}
类似这样的还有while(n--)后再次使用n