나누기와 나머지를 사용하면 쉽게 풀린다.
마지막 문자열을 뒤집는걸 잊어버리면 안됨
N, B = map(int, input().split())
result = ""
while N > 0:
if N % B >= 10:
result += str(chr(N % B + 55)) # 아스키코드 변환
else:
result += str(N % B)
N = int(N / B)
print(result[::-1]) # 문자열 뒤집기
'백준 > 일반 수학 1' 카테고리의 다른 글
백준 - 2869 (python) (0) | 2024.02.20 |
---|---|
백준 - 2292 (python) (0) | 2024.02.16 |
백준 - 2903 (python) (0) | 2024.02.15 |
백준 - 2720 (python) (0) | 2024.02.14 |
백준 - 2745 (python) (0) | 2024.02.14 |