Einfach 0 gelöst 0% Erfolgsquote

Cash: Fewest Coins

Give change with as few U.S. coins as possible.

Problem

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.

Einschränkungen

0 ≤ cents ≤ 1,000,000

Beispiele

Beispiel 1
Eingabe:
cents = 41

Erwartete Ausgabe:
expected = 4
Eingabe:
long long cents = 41;

Erwartete Ausgabe:
long long expected = 4;
Eingabe:
long cents = 41;

Erwartete Ausgabe:
long expected = 4;

Erläuterung

One quarter (25), one dime (35), one nickel (40) and one penny (41): 4 coins.

Beispiel 2
Eingabe:
cents = 0

Erwartete Ausgabe:
expected = 0
Eingabe:
long long cents = 0;

Erwartete Ausgabe:
long long expected = 0;
Eingabe:
long cents = 0;

Erwartete Ausgabe:
long expected = 0;

Erläuterung

No change is owed: 0 coins.

Referenzen

Diese Aufgabe wurde für CodeUtility angepasst. Beachte die oben genannten Vorgaben und Einschränkungen.

Von anderen lernen

Community-Lösungen

Noch keine veröffentlichten Lösungen. Löse die Aufgabe und teile als Erster eine Lösung.