#arc161b. [arc161_b]Exactly Three Bits
[arc161_b]Exactly Three Bits
Problem Statement
For a positive integer , let be the number of s that appear when is represented in binary notation. For example, $6 = 110_{(2)}, \\ 11 = 1011_{(2)}, \\ 16 = 10000_{(2)}$, so .
You are given a positive integer . Determine whether there is a positive integer less than or equal to such that , and if so, find the maximum such .
There are test cases to solve.
Constraints
Input
The input is given from Standard Input in the following format, where represents the value of in the -th test case:
Output
Print lines. The -th line should contain the maximum positive integer less than or equal to such that . If there is no such positive integer , print -1
.
Sample Input 1
4
16
161
4
1000000000000000000
Sample Output 1
14
161
-1
936748722493063168
- For the first test case, , so the maximum positive integer satisfying and is .
- For the second test case, , so the maximum positive integer satisfying and is .
- For the third test case, , so there is no positive integer satisfying and .
- As seen in the fourth test case, the input and output values may not fit in a 32-bit integer type.