You are given a sequence of \(N\) numbers. You can perform the following operation:
Select a number from the sequence and swap any pair of bits in its binary representation (Binary representation does not have any leading zeroes).
Output the lexicographic maximum sequence possible after performing 0 or more of the above operations.
Input format
- First line: A single integer \(N\) denoting the number of integers
- Second line: \(N\) integers denoting the array elements
Output format
Print \(N\) space-separated integers denoting the lexicographic maximum sequence possible.
Constraints
\(1 \leq N \leq 100000\)
\(1 \leq A_i \leq 10^{18}\)
Binary representation of 10 = 1010. Swap second and third bit to get the binary represenation as 1100 = 12.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor