황소개발자
백준 5585 파이썬 python 거스름돈 본문
반응형
1
2
3
4
5
6
7
8
9
10
11
12
|
price = int(input())
change = 1000 - price
arr = [500, 100, 50, 10, 5, 1]
count = 0
for i in arr:
count += change // i
change = change % i
print(count)
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
몫을 더해주고, 다음 for문으로 넘기기전에 나머지를 던져준다.
여기서 탐욕은 큰 동전부터 고려하는 것이다.
반응형
'백준 문제 풀이' 카테고리의 다른 글
백준 11727 파이썬 python (0) | 2019.10.31 |
---|---|
백준 2217 파이썬 python 로프 (0) | 2019.10.30 |
백준 1931 파이썬 python 회의실배정 (0) | 2019.10.28 |
백준 11047 파이썬 python 동전 0 @@황소처럼 우직하게@@ (0) | 2019.10.27 |
백준 11399 파이썬 python ATM (0) | 2019.10.26 |
Comments