URI Online Judge Solution 1018 Banknotes using Python Programming Language.
In this problem you have to read an integer value and calculate the smallest possible number of banknotes in which the value may be decomposed. The possible banknotes are 100, 50, 20, 10, 5, 2 e 1. Print the read value and the list of banknotes.
Input
The input file contains an integer value N (0 < N < 1000000).
Output
Print the read number and the minimum quantity of each necessary banknotes in Portuguese language, as the given example. Do not forget to print the end of line after each line, otherwise you will receive “Presentation Error”.
Input Sample | Output Sample |
576
|
576
5 nota(s) de R$ 100,00 1 nota(s) de R$ 50,00 1 nota(s) de R$ 20,00 0 nota(s) de R$ 10,00 1 nota(s) de R$ 5,00 0 nota(s) de R$ 2,00 1 nota(s) de R$ 1,00 |
11257
|
11257
112 nota(s) de R$ 100,00 1 nota(s) de R$ 50,00 0 nota(s) de R$ 20,00 0 nota(s) de R$ 10,00 1 nota(s) de R$ 5,00 1 nota(s) de R$ 2,00 0 nota(s) de R$ 1,00 |
503
|
503
5 nota(s) de R$ 100,00 0 nota(s) de R$ 50,00 0 nota(s) de R$ 20,00 0 nota(s) de R$ 10,00 0 nota(s) de R$ 5,00 1 nota(s) de R$ 2,00 1 nota(s) de R$ 1,00 |
Solution
M = int(input());
Hundred = Fifty = Twenty = Ten = Five = Two = One = Num = 0;
Num = M;
while M != 0:
if M >= 100:
Hundred = M / 100;
M = M % 100;
elif M >= 50:
Fifty = M / 50;
M = M % 50;
elif M >= 20:
Twenty = M / 20;
M = M % 20;
elif M >= 10:
Ten = M / 10;
M = M % 10;
elif M >= 5:
Five = M / 5;
M = M % 5;
elif M >= 2:
Two = M / 2;
M = M % 2;
else:
One = M;
M = 0;
print(Num);
print("%d nota(s) de R$ 100,00" % Hundred);
print("%d nota(s) de R$ 50,00" % Fifty);
print("%d nota(s) de R$ 20,00" % Twenty);
print("%d nota(s) de R$ 10,00" % Ten);
print("%d nota(s) de R$ 5,00" % Five);
print("%d nota(s) de R$ 2,00" % Two);
print("%d nota(s) de R$ 1,00" % One);
Comments
Post a Comment