int Lowbit(int x)
{
return x & (-x);
}
void Update(int x,int y,int d)
{
int i,j;
for(i=x;i<=s;i+=Lowbit(i))
{
for(j=y;j<=s;j+=Lowbit(j))
{
c[i][j]+=d;
}
}
}
LL Sum(int x,int y)
{
int i,j;
LL sum=0;
for(i=x;i>0;i-=Lowbit(i))
{
for(j=y;j>0;j-=Lowbit(j))
{
sum+=c[i][j];
}
}
return sum;
}
二维树状数组模版
最新推荐文章于 2022-11-22 20:14:19 发布