λλΆμ νμ΄μ¬μμ a//bκ° μ΄λ»κ² λμνλμ§ μ νν μ μ μμλ€.
μ΄λ κ² λμνλ€κ³ νλ€.
import sys
n = int(sys.stdin.readline())
if n == 0:
print(0)
else:
res = []
while n != 0:
if n%(-2) == 0:
res.append('0')
n = n//(-2)
else:
res.append('1')
n = n//(-2) +1
print(''.join(reversed(res)))
'π Algorithm > Python' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[Python] λ°±μ€ 1167, 1967 (0) | 2021.03.08 |
---|---|
[Python] λ°±μ€ 10917 (0) | 2021.03.07 |
[Python] λ°±μ€ 1442 (0) | 2021.02.25 |
[Python] λ°±μ€ 6549 (0) | 2021.02.20 |
[Python] λ°±μ€ 2606 (0) | 2020.09.01 |