自己对比吧
```cpp
#include <bits/stdc++.h>
#define newline printf ("\n")
#define space printf (" ")
#define cinfalse ios::sync_with_stdio(false)
#define MAXN 500005
using namespace std;
int n, m;
long long c[MAXN];
int Lowbit (int x)
{
return x&(-x);
}
void add (int pos, int x)
{
while (pos <= n)
c[pos] += x, pos += Lowbit(pos);
return ;
}
long long query (int x)
{
long long res = 0;
while (x > 0)
res += c[x], x -= Lowbit(x);
return res;
}
int main()
{
scanf ("%d %d", &n, &m);
for (int i = 1, a; i <= n; i ++)
scanf ("%d", &a), add (i, a);
for (int i = 0, a, b, c; i < m; i ++)
{
scanf ("%d %d %d", &a, &b, &c);
if (a == 1)
add (b, c);
else
printf ("%lld\n", query(c)-query(b-1));
}
return 0;
}
```
by tocek_shiki @ 2018-09-22 14:28:42
@[fff团666](/space/show?uid=49562) 哇,巨啊
by Chloris @ 2018-09-22 14:41:25
@[fff团666](/space/show?uid=49562)
哇,聚啊
by shadowice1984 @ 2018-09-22 14:42:40
@[Chloristendika](/space/show?uid=76527)
$$\text{被巨佬膜的我受宠若惊}$$
by tocek_shiki @ 2018-09-22 14:48:40
@[shadowice1984](/space/show?uid=56384) 我弱爆了
by tocek_shiki @ 2018-09-22 14:48:53
你的数值变化方向反了,完美地求成了后缀和(忽然想起ZJOI的一道题)
by 142857cs @ 2018-09-22 14:56:08
```cpp
void change(int i,int n){
while(i<=n){
c[i]+=n;
i+=lowbit(i);
}
}
```
你都int n了
by AzusaCat @ 2018-09-22 15:05:51
改完已ac@[aeber233](/space/show?uid=47657)
by AzusaCat @ 2018-09-22 15:07:27
感谢各位巨佬。。
其实发完后两分钟就已经A了(逃
by 牙神幻十郎 @ 2018-09-22 15:09:07