Today
Total
04-19 14:48
관리 메뉴

홍우진의 개발 일기장

[백준] 11576번: Base Conversion / 파이썬 본문

알고리즘/백준

[백준] 11576번: Base Conversion / 파이썬

홍우진 2025. 2. 11. 22:06
728x90
반응형

문제 링크


https://www.acmicpc.net/problem/11576

풀이 코드


a, b = map(int,input().split())
m = int(input()) - 1
n, ans = 0, []

for i in map(int,input().split()):
    n += i * a ** m
    m -= 1
    
while n:
    ans.append(n % b)
    n //= b

print(*ans[::-1])

코드 해석


a진법을 10진법으로 변환 한 뒤 다시 b진법으로 변환한다.

 

체감 난이도: ★☆☆☆

728x90
반응형
Comments