求助树状数组

P3374 【模板】树状数组 1

@[朕在世界之巅](/user/356740) 小郝人:前排
by Dry_ice @ 2020-07-29 19:34:54


```cpp inline void add(int x, int d) { while(x<=n) { tree[x] += d; x -= lowbit(x); } } ``` 你再看看?
by 小恐 @ 2020-07-29 19:35:20


@[小恐](/user/173840) 哦woc 谢谢
by 朕在世界之巅 @ 2020-07-29 19:35:54


@[小恐](/user/173840) 依然[TLE](https://www.luogu.com.cn/record/36012034)
by 朕在世界之巅 @ 2020-07-29 19:40:54


@[朕在世界之巅](/user/356740) 你lowbit是什么鬼
by 小恐 @ 2020-07-29 19:42:48


@[朕在世界之巅](/user/356740) lowbit(x)=x&(-x)
by 小恐 @ 2020-07-29 19:43:28


@[小恐](/user/173840) 咋啦 这不是宏定义?防止表达式出现优先级问题
by 朕在世界之巅 @ 2020-07-29 19:44:29


@[小恐](/user/173840) 依然[TLE](https://www.luogu.com.cn/record/36012415)
by 朕在世界之巅 @ 2020-07-29 19:45:33


@[朕在世界之巅](/user/356740) ```cpp #define lowbit(x) ((x) & (-x)) ``` 正确写法
by 小恐 @ 2020-07-29 19:45:34


说不定写成函数就好了
by 5ab_juruo @ 2020-07-29 19:46:30


| 下一页