aboutsummaryrefslogtreecommitdiff
path: root/Data Structures
diff options
context:
space:
mode:
authorTa180m2020-04-20 22:22:35 -0500
committerTa180m2020-04-20 22:22:35 -0500
commitdbf633771d50d451286be19fd9cef41d04839ef4 (patch)
treec04e9a9d19ba7765c809229a0b144fb7bdf6d0d4 /Data Structures
parentb7c7075fe649ea7494920aa94d07fa9a76e2d0cd (diff)
update fenwick tree
Diffstat (limited to 'Data Structures')
-rw-r--r--Data Structures/fenwick_tree.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Data Structures/fenwick_tree.cpp b/Data Structures/fenwick_tree.cpp
index 4bd7354..aa87001 100644
--- a/Data Structures/fenwick_tree.cpp
+++ b/Data Structures/fenwick_tree.cpp
@@ -4,5 +4,5 @@ public:
fenwick_tree(int N) { FT.assign(N + 1, 0); }
void update(int x, T val) { if (x > 0) for (; x < FT.size(); x += x & -x) FT[x] += val; }
T query(int x) { T ret = 0; if (x > 0) for (; x > 0; x -= x & -x) ret += FT[x]; return ret; }
- T query(int x, int y) { return query(y) - (x == 1 ? 0 : query(x - 1)); }
+ T query(int x, int y) { return query(y) - query(x - 1); }
}; \ No newline at end of file