public static long findMinLegalValue(
            Function<Long, Boolean> legalChecker, long low, long high) {
        if (!legalChecker.apply(high)) {
            return -1;
        }
        while (low <= high) {
            long mid = (low + high) / 2;
            if (legalChecker.apply(mid)) {
                high = mid - 1;
            } else {
                low = mid + 1;
            }
        }
        return high + 1;
    }
@Test
    void testFindMinLegalValue() {
        assertThat(BisectionSearchUtils.findMinLegalValue(value -> 29 / value <= 3, 1, 17))
                .isEqualTo(8);
        assertThat(BisectionSearchUtils.findMinLegalValue(value -> 29 / value <= 3, 8, 17))
                .isEqualTo(8);
        assertThat(BisectionSearchUtils.findMinLegalValue(value -> 29 / value <= 3, 1, 8))
                .isEqualTo(8);
        assertThat(BisectionSearchUtils.findMinLegalValue(value -> 29 / value <= 3, 9, 17))
                .isEqualTo(9);
        assertThat(BisectionSearchUtils.findMinLegalValue(value -> 29 / value <= 3, 1, 7))
                .isEqualTo(-1);
    }