树状数组

来源:互联网 发布:批处理 base64源码 编辑:程序博客网 时间:2024/06/18 09:10
// 树状数组int c[maxn];int lowbit(int x) {    return x & (-x);}while add(int x, int y) {    while(x < maxn)  {        c[x] += y;        x += lowbit(x);    }}int sum (int x) {    int s = 0;    while(x > 0) {        s += c[x];        x -= lowbit[x];    }    return x;}

http://www.cnblogs.com/hsd-/p/6139376.html

原创粉丝点击