Maximum bit shifts
Practice
3 (14 votes)
Basic programming
Bit manipulation
Problem
49% Success 3481 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
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
111 votes
Tags:
Basic ProgrammingBit manipulationEasy
Points:30
150 votes
Tags:
ReadyBrute-force searchEasy-MediumApprovedBreadth-first search
Points:20
14 votes
Tags:
Basics of bit manipulationBitmaskImplementationMerge SortBit ManipulationAlgorithmsBasic ProgrammingSortingBasics of Bit Manipulation
Editorial
Login to unlock the editorial