본문 바로가기

Programming [Python]/백준 알고리즘 솔루션

#224 백준 파이썬 [5585] 거스름돈

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

 

Python Code

money = 1000 - int(input())

coin = 0
while money != 0:
    for num in [500, 100, 50, 10, 5, 1]:
        while money >= num: 
            money -= num
            coin += 1

print(coin)