模板树状树组

Posted akakw1

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了模板树状树组相关的知识,希望对你有一定的参考价值。

 

template<typename T> struct BIT {
	T *s; int lim;
	void init(int x) { lim = x, s = new T[x + 1], memset(s, 0, (lim + 1) * sizeof(int)); }
	void update(int x, T c) { for(;x <= lim; x += x & -x)s[x] += c; }
	T query(int x) { T ans = 0; for(; x; x -= x & -x)ans += s[x]; return ans; }
};

 

以上是关于模板树状树组的主要内容,如果未能解决你的问题,请参考以下文章