Maximum bit shifts
Practice
3 (14 votes)
Basic programming
Bit manipulation
Problem
49% Success 3480 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

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}\)

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

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
19 votes
Tags:
Basic ProgrammingBit ManipulationBasics of Bit Manipulation
Points:30
17 votes
Tags:
Easy
Points:20
11 votes
Tags:
BitmaskBasics of Bit ManipulationBasic ProgrammingBit ManipulationBit manipulationBasics of bit manipulation