BOJ/백준-3460-Python

cosmos·2023년 4월 12일
0
post-thumbnail

문제

코드

# https://www.acmicpc.net/problem/3460
# boj, 3460: 이진수, Python3
def solve(t: int):
    for _ in range(t):
        num = format(int(input()), 'b')

        for index, x in enumerate(list(reversed(str(num)))):
            if x == '1':
                print(index, end=' ')

if __name__ == '__main__':
    t = int(input())

    solve(t)

결과

출처 & 깃허브

boj 3460
github

0개의 댓글