Problem 354
Reverse Bits
Easy · 10 pts · Bit Manipulation
Problem
Treat N as a 32-bit unsigned integer, so it has exactly 32 bits including leading zeros. Reverse the order of those 32 bits (bit 0 becomes bit 31, bit 1 becomes bit 30, and so on) and print the resulting unsigned number. In languages without unsigned types, be careful that the result can be as large as 2^32 - 1.
Input
A single integer N.
Output
Print the value of N with its 32 bits reversed.
Constraints
0 <= N <= 4294967295
Example input
1
Example output
2147483648
Explanation
1 is 000...0001 in 32 bits. Reversed it becomes 1000...000, which is 2^31 = 2147483648.