Programming/Python & Data Structures
[Baekjoon/Python3] 3460번 이진수
HooNeee
2020. 12. 4. 17:24
[Baekjoon/Python3] 3460번 이진수
3460번: 이진수
양의 정수 n이 주어졌을 때, 이를 이진수로 나타냈을 때 1의 위치를 모두 찾는 프로그램을 작성하시오. 최하위 비트(least significant bit, lsb)의 위치는 0이다.
www.acmicpc.net
t = int(input())
for i in range(t):
n = int(input())
n = str(bin(n)[2:])
for j in range(1, len(n) + 1):
if n[-j] == '1':
print(j - 1, end=' ')