1970 쉬운 거스름돈

김은서·2021년 8월 4일
0

SWEA

목록 보기
22/47

풀이

사용하는 돈의 액수가 큰 것부터 작은 순서대로 나누었을 때의 나머지가 0보다 크면 빈 리스트에 개수를 추가하여 마지막에 출력한다.

python 코드

T = int(input())
for tc in range(1, T+1):
    N = int(input())
    total = []
    if N // 50000 > 0:
        total.append(N // 50000)
        N = N % 50000
    if N // 10000 > 0:
        total += N // 10000
        N = N % 10000
    if N // 5000 > 0:
        total += N // 5000
        N = N % 5000
    if N // 1000 > 0:
        total += N // 1000
        N = N % 1000
    if N // 500 > 0:
        total += N // 500
        N = N % 500  
    if N // 100 > 0:
        total += N // 100
        N = N % 100 
    if N // 50 > 0:
        total += N // 50
        N = N % 50
    if N // 10 > 0:
        total += N // 100
        N = N % 10 
    
    print(total)
profile
Gracelog

0개의 댓글