Time Limit: 2 seconds memory limit: 65536 KB
Given a positive integer N, print out the positions of all 1's in its binary representation. The position of the least significant bit is 0.
Example
The positions of 1's in the binary representation of 13 are 0, 2, 3.
Task
Write a program which for each data set:
Reads a positive integer N,
Computes the positions of 1's in the binary representation of N,
Writes the result.
Input
The first line of the input contains exactly one positive integer d equal to the number of data sets, 1 <= d <= 10. The data sets follow.
Each data set consists of exactly one line containing exactly one integer N, 1 <= n <= 10 ^ 6.
Output
The output shoshould consists of exactly D lines, one line for each data set.
Line I, 1 <= I <= D, shoshould contain increasing sequence of integers separated by single spaces-the positions of 1's in the binary representation of the I-th input number.
Sample Input
1
13
Sample output
0 2 3
Source:Central Europe 2001, practice
Note The control of spaces in the output format!
# Include <iostream>
Using NamespaceSTD;
IntMain ()
{
IntNums; CIN> Nums;
IntNumber;
While(Nums -- & CIN> Number)
{
IntJ = 0;
For(IntI = 0; number >>=1, I ++)
{
If(Number & 1> 0)
{
If(J! = 0)
Cout <" ";
Cout <I;
J ++;
}
}
Cout <Endl;
}
Return0;
}