summaryrefslogtreecommitdiff
path: root/datastructures/fenwickTree2.cpp
diff options
context:
space:
mode:
authorGloria Mundi <gloria@gloria-mundi.eu>2024-06-23 01:13:23 +0200
committerGloria Mundi <gloria@gloria-mundi.eu>2024-06-23 01:13:23 +0200
commita6e8d68a9b406027f48fb81cae6cf13d073ffa5a (patch)
treef80b7e855666a6e092534016972e97ee30a6e65e /datastructures/fenwickTree2.cpp
parent7f040b63d7581985b399d7eab1762b0951f49dde (diff)
simplify fenwick tree
Diffstat (limited to 'datastructures/fenwickTree2.cpp')
-rw-r--r--datastructures/fenwickTree2.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/datastructures/fenwickTree2.cpp b/datastructures/fenwickTree2.cpp
index 086e785..7fcdbb9 100644
--- a/datastructures/fenwickTree2.cpp
+++ b/datastructures/fenwickTree2.cpp
@@ -7,7 +7,7 @@ void update(int l, int r, ll val) {
add[tr] -= val, mul[tr] += val * r;
}
-void init(vector<ll>& v) {
+void init(vector<ll> &v) {
mul.assign(size(v) + 1, 0);
add.assign(size(v) + 1, 0);
for(int i = 0; i < ssize(v); i++) update(i, i + 1, v[i]);
@@ -15,7 +15,7 @@ void init(vector<ll>& v) {
ll prefix_sum(int i) {
ll res = 0;
- for (int ti = i; ti > 0; ti -= ti & -ti)
+ for (int ti = i; ti > 0; ti &= ti-1)
res += add[ti] * i + mul[ti];
return res;
}