1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <stdio.h> int money[6] = { 500,100,50,10,5,1 }; int main() { int total, idx = 0, rst = 0; scanf("%d", &total); total = 1000 - total; while (idx <= 5) { while (total >= money[idx]) { total -= money[idx]; rst++; } idx++; } printf("%d", rst); } | cs |
'알고리즘 > 그리디 알고리즘' 카테고리의 다른 글
10610 30 (0) | 2019.06.22 |
---|---|
2217 로프 (0) | 2019.06.22 |
11399 ATM (0) | 2019.06.22 |
테이블 옮기기 더블릿 (0) | 2019.02.20 |
마감시간을 가지는 작업 더블릿 (0) | 2019.02.20 |