diff options
-rw-r--r-- | segmenttree.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/segmenttree.c b/segmenttree.c index e9f38da..efd2fb7 100644 --- a/segmenttree.c +++ b/segmenttree.c @@ -9,7 +9,7 @@ void build(sqlite3_stmt *stmt, int l, int r, int n) { seg[n] = sqlite3_column_int(stmt, 0); return; } - int m = l + r >> 1; + int m = (l + r) >> 1; build(stmt, l, m, n << 1); build(stmt, m + 1, r, n << 1 | 1); seg[n] = seg[n << 1] + seg[n << 1 | 1]; @@ -21,7 +21,7 @@ void update(int x, int v, int l, int r, int n) { seg[n] = v; return; } - int m = l + r >> 1; + int m = (l + r) >> 1; if (x <= m) { update(x, v, l, m, n<<1); } @@ -38,7 +38,7 @@ void query(int *res, int v, int l, int r, int n) { res[1] = l; return; } - int m = l + r >> 1; + int m = (l + r) >> 1; if (seg[n << 1] > v) { query(res, v, l, m, n << 1); } |