树状数组模板
教程有时间补上
const int MAXN = 500000 + 10; int s[MAXN]; int n,m; inline int lowbit(int k) { return k&(-k); } inline int ask(int k) { int sum = 0; for(int i = k;i;i -= lowbit(i)) { sum += s[i]; } return sum; } inline void modefy(int k, int num) { for(int i = k;i <= n;i += lowbit(i)) { s[i] += num; } } inline int ask(int l,int r) { return ask(r) - ask(l - 1); }