2012年6月4日

【模板】树状数组 01

摘要: 一维树状数组简单操作(以下代码均从数组下标1开始)c[i] 表示 元素1 到 元素i 的 和#include <cstdio>#include <cstring>using namespace std;const int MXN = 100010;int c[MXN],n;int lowbit(int x) {return x & (-x);}void modify(int x,int val) { while (x<=n) c[x] += val,x += lowbit(x);}int query(int x) { int sum = 0; while 阅读全文

posted @ 2012-06-04 22:29 vjudge 阅读(371) 评论(0) 推荐(0)

导航