0
Enunciation:
Read a floating point value to two decimal places. This value represents a monetary value. Next, calculate the smallest number of possible banknotes and coins into which the value can be broken down. Banknotes are 100, 50, 20, 10, 5, 2. The possible currencies are 1, 0.50, 0.25, 0.10, 0.05 and 0.01. Show below the list of notes necessary.
Entree
The input file contains a floating point value N (0 N 1000000.00).
Exit
Print the minimum amount of banknotes and coins needed to exchange the initial value, as shown in the example provided.
Note: Use dot (.) to separate the decimal part.
(https://www.urionlinejudge.com.br/judge/pt/problems/view/1021)
My code:
# -*- coding: utf-8 -*-
valor = float(input())
cem_r = int(valor // 100)
valor %= 100
cinquenta_r = int(valor // 50)
valor %= 50
vinte_r = int(valor // 20)
valor %= 20
dez_r = int(valor // 10)
valor %= 10
cinco_r = int(valor // 5)
valor %= 5
dois_r = int(valor // 2)
valor %= 2
um_r = int(valor // 1)
valor %= 1
cinquenta_c = int(valor // 0.50)
valor %= 0.50
vintecinco_c = int(valor // 0.25)
valor %= 0.25
dez_c = int(valor // 0.10)
valor %= 0.10
cinco_c = int(valor // 0.05)
valor %= 0.05
um_c = int(valor // 0.01)
print("""NOTAS:
{} nota(s) de R$ 100.00
{} nota(s) de R$ 50.00
{} nota(s) de R$ 20.00
{} nota(s) de R$ 10.00
{} nota(s) de R$ 5.00
{} nota(s) de R$ 2.00
MOEDAS:
{} moeda(s) de R$ 1.00
{} moeda(s) de R$ 0.50
{} moeda(s) de R$ 0.25
{} moeda(s) de R$ 0.10
{} moeda(s) de R$ 0.05
{} moeda(s) de R$ 0.01""".format(cem_r, cinquenta_r, vinte_r, dez_r, cinco_r,
dois_r, um_r, cinquenta_c, vintecinco_c, dez_c,
cinco_c, um_c))
I performed all the tests available on the site and, in all, worked as expected.
Even so I keep getting the message "Wrong Answer (100%)", which means I missed 100% of the question.
What do you mean? Where’s my mistake?
Another possibility is to multiply all values by 100, work with integers and, if necessary, divide the values by 100 when printing.
– anonimo