Binary Number
InterviewTime limit1sMemory limit128 MB
For each given integer, output the positions of all bits set to 1 in its binary representation, from least to most significant.
- Level
Easy2 of 10
- Topics
- Bit manipulation, Implementation
- Solved
- No attempts yet
Problem
You are given a positive integer . Write a program that finds the positions of all bits equal to in the binary representation of . Bit positions are numbered starting from the least significant bit (LSB), which is position , and increase by toward the most significant bit.
Input
The first line contains the number of test cases . Each of the next lines contains a single integer .
Output
For each test case, print on one line the positions of the bits equal to , in increasing order of position, separated by single spaces.