https://www.acmicpc.net/problem/11005
11005번: 진법 변환 2
10진법 수 N이 주어진다. 이 수를 B진법으로 바꿔 출력하는 프로그램을 작성하시오. 10진법을 넘어가는 진법은 숫자로 표시할 수 없는 자리가 있다. 이런 경우에는 다음과 같이 알파벳 대문자를
www.acmicpc.net
number, base = map(int, input().split())
t = number
result = []
while t != 0:
t, r = divmod(t, base)
if r >= 10:
r = ord("A") + (r-10)
result.append(chr(r))
else:
result.append(str(r))
print("".join(reversed(result)))
'알고리즘 > 백준-파이썬' 카테고리의 다른 글
[백준] 11576번 (python 파이썬) (0) | 2022.04.14 |
---|---|
[백준] 2745번 (python 파이썬) (0) | 2022.04.14 |
[백준] 17103번 (python 파이썬) (0) | 2022.04.13 |
[백준] 2089번 (python 파이썬) (0) | 2022.04.13 |
[백준] 1212번 (python 파이썬) (0) | 2022.04.12 |