MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / query

Method query

src/class111/Code03_SquareRoot.java:73–86  ·  view source on GitHub ↗
(int jobl, int jobr, int l, int r, int i)

Source from the content-addressed store, hash-verified

71 // 没有懒更新
72 // 不需要调用down方法
73 public static long query(int jobl, int jobr, int l, int r, int i) {
74 if (jobl <= l && r <= jobr) {
75 return sum[i];
76 }
77 int mid = (l + r) >> 1;
78 long ans = 0;
79 if (jobl <= mid) {
80 ans += query(jobl, jobr, l, mid, i << 1);
81 }
82 if (jobr > mid) {
83 ans += query(jobl, jobr, mid + 1, r, i << 1 | 1);
84 }
85 return ans;
86 }
87
88 public static void main(String[] args) throws IOException {
89 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected