Skip to content

Latest commit

 

History

History
28 lines (27 loc) · 431 Bytes

树状数组区间查询.md

File metadata and controls

28 lines (27 loc) · 431 Bytes
tags title created modified
Code
树状数组区间查询
2022-09-02T13:05:00.280Z
2022-09-02T13:05:29.343Z

树状数组区间查询

typedef long long ll;
int c[50010];
int n;
string s;
void update(int p, int val)
{
	for (int i = p; i <= n; i += i & -i) {
		c[i] += val;
	}
}
int sum(int p)
{
	int ret = 0;
	for (int i = p; i > 0; i -= i & -i) {
		ret += c[i];
	}
	return ret;
}