树状数组模板

namespace BIT {
	int tr[/*数据范围 qwq*/], N;
	void init(int n) { N = n; for (int i = 1; i <= n; i ++) tr[i] = 0;}
	void update(int x, int y) { for (; x <= N; x += (x & (-x))) tr[x] += y;}
	int query(int x) { int res = 0; for (; x; x -= (x & (-x))) res += tr[x]; return res;}
} using namespace BIT;

作者:DE_aemmprty

出处:https://www.cnblogs.com/aemmprty/p/17758824.html

版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。

posted @   DE_aemmprty  阅读(35)  评论(3编辑  收藏  举报
相关博文:
阅读排行:
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· 【.NET】调用本地 Deepseek 模型
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
more_horiz
keyboard_arrow_up light_mode palette
选择主题
点击右上角即可分享
微信分享提示