URI Online Judge Solution 1021 | Banknotes and Coins - URI 1021 Solution in C,C++,Python

URI Online Judge Solution  1021 | Banknotes and Coins - URI 1021 Solution in C,C++,Python

Read a value of floating point with two decimal places. This represents a monetary value. After this, calculate the smallest possible number of notes and coins on which the value can be decomposed. The considered notes are of 100, 50, 20, 10, 5, 2. The possible coins are of 1, 0.50, 0.25, 0.10, 0.05 and 0.01. Print the message “NOTAS:” followed by the list of notes and the message “MOEDAS:” followed by the list of coins.

Input

The input file contains a value of floating point (0 ≤ ≤ 1000000.00).

Output

Print the minimum quantity of banknotes and coins necessary to change the initial value, as the given example.

Input SampleOutput Sample

576.73

NOTAS:
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
MOEDAS:
1 moeda(s) de R$ 1.00
1 moeda(s) de R$ 0.50
0 moeda(s) de R$ 0.25
2 moeda(s) de R$ 0.10
0 moeda(s) de R$ 0.05
3 moeda(s) de R$ 0.01

URI Online Judge Solution  1021 | Banknotes and Coins - URI 1021 Solution in C,C++,Python:


  URI Problem 1021 Solution in C :   

  URI Online Judge 1021 Solve  in C :                                                                             
#include <stdio.h>
 
int main()
 
{
 
    double n, d[] = {100.0, 50.0, 20.0, 10.0, 5.0, 2.0, 1.0, 0.5, 0.25, 0.10, 0.05, 0.01};
 
    int t = 0, c;
 
    scanf("%lf", &n);
 
    printf("NOTAS:\n");
 
    t = 0;
 
    n+=1e-9;
 
    while (d[t] >= 0.01)
 
    {
 
        c = 0;
 
        while (n >= d[t])
 
        {
 
            n -= d[t];
 
            c++;
 
        }
 
        if (d[t] == 1.0)
 
            printf("MOEDAS:\n");
 
        if (d[t] >= 2.0 )
 
            printf("%d nota(s) de R$ %.2f\n", c, d[t]);
 
        else
 
            printf("%d moeda(s) de R$ %.2f\n", c, d[t]);
 
        t++;
 
    }
 
    return 0;
 
}

2 Responses to URI Online Judge Solution 1021 | Banknotes and Coins - URI 1021 Solution in C,C++,Python