[python] 백준 2720번 풀이

김보현·2024년 6월 11일
0

PS

목록 보기
27/62

정답

t = int(input())
change = {'Q':25, 'D':10, 'N': 5, 'P': 1}
for i in range(t):
    c = int(input())
    q = c//change['Q']
    q_next = c%change['Q']
    d = q_next//change['D']
    d_next = q_next%change['D']
    n = d_next//change['N']
    n_next = d_next%change['N']
    p = n_next//change['P']
    print(q, d, n, p)

다른풀이

print(c//q, c%q//d, c%q%d//n, c%q%d%n//p)

dictionary를 쓰는대신 변수에 25,10,5,1을 넣어놓고 한번에 프린트할 수 있다.

profile
Fall in love with Computer Vision

0개의 댓글

관련 채용 정보