← Back to List

1740번: 거듭제곱 ↗

Solutions

Python 3
150 B | 150 chars
def f(x):
    if x > 0:
        f(x//2)
    print(x%2)

a = int(input())
c = 1
ans = 0
while a>0:
    ans += c * (a%2)
    c *= 3
    a//=2
print(ans)