PS/BOJ
[백준] -2진수
RUBY_루비
2020. 9. 30. 23:59
출처:: www.acmicpc.net/problem/2089
분류::
1. 문제 이해 및 해결과정
2. 풀이방법
1.
#-2진수
#https://www.acmicpc.net/problem/2089
import sys
sys.stdin = open("input.txt","r")
input=sys.stdin.readline
n=int(input())
res=[]
if n==0:
print('0')
exit(0)
while n:
# print(n)
if n%-2: #나머지 있으면
n=n//-2+1
res.append('1')
else:
n=n//-2
res.append('0')
print(''.join(reversed(res)))
3. 오답원인
- 0일때 처리안해서 틀림
4. 알게된 점