tags | title | created | modified | |
---|---|---|---|---|
|
树状数组区间查询 |
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;
}