Dowemo
0 0 0 0

int lowbit(int x) {return x&(-x);}intsum(int i)//求前i项和{
 int s=0;
 while(i>0)
 {
 s+=bit[i];
 i-=lowbit(i);
 }
 return s;
}void add(int i,int val)
{
 while(i<=n)
 {
 bit[i]+=val;
 i+=lowbit(i);
 }
}



Copyright © 2011 Dowemo All rights reserved.    Creative Commons   AboutUs