#C11897. Guess the Hidden Integer
Guess the Hidden Integer
Guess the Hidden Integer
A friend holds a hidden integer \(y\) in the range \(0 \le y \le 2^{30}-1\). Your task is to determine this hidden integer using a binary search strategy. At each step, you compare your guess with the hidden number by using a helper function is_greater(y, k)
that returns true if \(y > k\) and false otherwise.
The binary search recursively narrows down the search range until the exact value is found. This method guarantees a worst-case time complexity of \(O(\log(2^{30}))\). Use this strategy to implement a function that guesses the hidden integer with a minimum number of comparisons.
inputFormat
The input consists of a single integer \(y\) (\(0 \le y \le 2^{30}-1\)) representing the hidden integer.
outputFormat
Output a single integer which is the guessed hidden integer.
## sample0
0