voidsolve() { while (T-- > 0) { intl= in.nextInt(), r = in.nextInt(), c = in.nextInt(); intll= l, rr = r; intcnt= (r - l + 1); intk=0; while (cnt > 0) { k++; cnt /= 2; } if (k < c) { out.println(-1); continue; } intlx= ll, rx = (ll + rr) / 2; while (lx < rx) { intmmid= lx + rx + 1 >> 1; if (f(ll, rr, mmid) <= c) lx = mmid; else rx = mmid - 1; } if (f(ll, rr, rx) == c) out.println(rx); else { lx = (ll + rr) / 2; rx = rr; while (lx < rx) { intmmid= lx + rx + 1 >> 1; if (f(ll, rr, mmid) <= c) lx = mmid; else rx = mmid - 1; } out.println(rx); } } }
intf(int l, int r, int x) { // l <= x <= r intcnt=0; while (l <= r) { cnt++; intmid= (l + r) / 2; if (mid == x) break; if (mid < x) l = mid + 1; else r = mid - 1; } return cnt; }