Counting 1's
Time limit8sMemory limit256 MB
Given how many numbers in the hidden interval [A, B] have each binary bit set, recover A and B or report Many or None.
- Level
Hard8 of 10
- Topics
- Bit manipulation, Math
- Solved
- No attempts yet
Problem
Let be the -th least significant bit of , that is, the -th least significant digit of written in base 2 (). For example, , so , , , and for every .
The integers and satisfy . Let be the number of integers with and .
Given , determine and .
Input
The input consists of several datasets. The number of datasets is at most 100,000. Each dataset has this format:
n
k1
k2
...
kn
The first line of a dataset contains the integer (). Each of the next lines contains one (). For every , .
The last line of the input contains . Print nothing for that line.
Output
Print one line for each dataset.
- If and are uniquely determined, print and separated by a single space.
- If more than one pair fits, print
Manywithout the quotes. - If no pair fits, print
Nonewithout the quotes.