Условие
A cashier gives change using quarters (25¢), dimes (10¢), nickels (5¢) and pennies (1¢). Always using the largest coin that still fits gives the fewest coins for these values. Return how many coins are needed for cents.
Implement fewest_coins(cents).
Input
cents: The change owed in cents.
Output
Return the minimum number of coins.
Ограничения
0 ≤ cents ≤ 1,000,000
Примеры
Ввод:
cents = 41
Ожидаемый вывод:
expected = 4
Ввод:
long long cents = 41;
Ожидаемый вывод:
long long expected = 4;
Ввод:
long cents = 41;
Ожидаемый вывод:
long expected = 4;
Пояснение
One quarter (25), one dime (35), one nickel (40) and one penny (41): 4 coins.
Ввод:
cents = 0
Ожидаемый вывод:
expected = 0
Ввод:
long long cents = 0;
Ожидаемый вывод:
long long expected = 0;
Ввод:
long cents = 0;
Ожидаемый вывод:
long expected = 0;
Пояснение
No change is owed: 0 coins.
Ссылки
Это задание адаптировано для CodeUtility. Следуйте условию и ограничениям выше.