Reverse Bits
easyBit Manipulation+10 XPTime limit 2s
Treat each number as an unsigned 32-bit integer and reverse the order of its 32 bits (bit 0 becomes bit 31, bit 1 becomes bit 30, …). Print the result as an unsigned number.
Example: 43261596 = 00000010100101000001111010011100₂ → 00111001011110000010100101000000₂ = 964176192.
Input:
- line 1:
q - next
qlines: one integerxeach
Output: for every x, the reversed value on its own line.
Constraints: 1 ≤ q ≤ 10⁵, 0 ≤ x < 2³².
Watch out: results can be ≥ 2³¹ — use 64-bit or unsigned types. Build the answer bit by bit: result = (result << 1) | (x & 1); x >>= 1, 32 times.
Sample input 1
2 43261596 4294967293
Sample output 1
964176192 3221225471
Sample input 2
2 0 1
Sample output 2
0 2147483648
📖 Stuck? Learn the pattern
Read input from standard input and print the answer to standard output. Your code runs in a secure sandbox against the samples (Run) and hidden tests (Submit).