백준 문풀
[Python] 구현 - 11005.진법변환2(브1)
브로코딩
2023. 8. 6. 07:29
https://www.acmicpc.net/problem/11005
11005번: 진법 변환 2
10진법 수 N이 주어진다. 이 수를 B진법으로 바꿔 출력하는 프로그램을 작성하시오. 10진법을 넘어가는 진법은 숫자로 표시할 수 없는 자리가 있다. 이런 경우에는 다음과 같이 알파벳 대문자를
www.acmicpc.net
>>문제포인트
: 기존 진법변환 알고리즘에서 나머지가 10이상일 때 문자열로 변환하는 것
: 문자데이터와 숫자 데이터를 리스트에서 통일하여 합치기
: map함수를 사용하면 함수의 일괄 적용이 편하다.
def change(a):
if a>=10:
return chr(a+55)
else:
return a
result=[]
a,b= map(int, input().split())
while (a!=0):
x,y= divmod(a,b)
result.append(y)
a=x
result= map(change, result)
result= map(str, result)
result=''.join(result)
print(result[::-1])