From a6e8d68a9b406027f48fb81cae6cf13d073ffa5a Mon Sep 17 00:00:00 2001 From: Gloria Mundi Date: Sun, 23 Jun 2024 01:13:23 +0200 Subject: simplify fenwick tree --- datastructures/fenwickTree.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'datastructures/fenwickTree.cpp') diff --git a/datastructures/fenwickTree.cpp b/datastructures/fenwickTree.cpp index 8c73b78..7013613 100644 --- a/datastructures/fenwickTree.cpp +++ b/datastructures/fenwickTree.cpp @@ -10,6 +10,6 @@ void init(int n) { ll prefix_sum(int i) { ll sum = 0; - for (; i > 0; i -= i & -i) sum += tree[i]; + for (; i > 0; i &= i-1) sum += tree[i]; return sum; } -- cgit v1.2.3