#K11586. Next Power of Two
Next Power of Two
Next Power of Two
Given a list of positive integers, for each integer (n), compute the smallest power of two that is greater than or equal to (n). In other words, find the smallest number of the form (2^k) such that (2^k \ge n).
Mathematically, the answer for a given number (n) is (2^{\lceil \log_2 n \rceil}). This problem tests your ability to work with logarithms, bit manipulation, and efficient looping constructs.
inputFormat
The first line contains a single integer (T) — the number of test cases. Each of the next (T) lines contains one positive integer (n).
outputFormat
For each test case, output a single line containing the smallest power of two greater than or equal to (n).## sample
3
5
15
20
8
16
32
</p>