// 2.1.1 区间被划分成 [l, mid] 和 [mid + 1, r] intbsearch_1(int l, int r){ while (l < r) { int mid = l + r >> 1; if (check(mid)) r = mid; else l = mid + 1; } return l }
// 2.1.2 区间被划分成 [l, mid - 1] 和 [mid, r] intbsearch_2(int l, int r) { while (l < r) { int mid = l + r + 1 >> 1; if (chedk(mid)) l = mid; else r = mid - 1; } }