Ad Code

Responsive Advertisement

Uri - Beecrowd | 1021 | Banknotes and Coins

beecrowd | 1021

Banknotes and Coins

Adapted by Neilor Tonin, URI Brazil


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 Sample Output 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

4.00

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

91.01

NOTAS:
0 nota(s) de R$ 100.00
1 nota(s) de R$ 50.00
2 nota(s) de R$ 20.00
0 nota(s) de R$ 10.00
0 nota(s) de R$ 5.00
0 nota(s) de R$ 2.00
MOEDAS:
1 moeda(s) de R$ 1.00
0 moeda(s) de R$ 0.50
0 moeda(s) de R$ 0.25
0 moeda(s) de R$ 0.10
0 moeda(s) de R$ 0.05
1 moeda(s) de R$ 0.01

N.B.: It's better if you solve this by your own. Thank you!

  URI - BEECROWD Online Judge 1021 Solve  in C :                                          

//Solved by Intesar
#include <stdio.h>

int main(){
    double N;
    int inteiro, aux, aux1;

    scanf("%lf",&N);

    inteiro = N;
    N = 100*N;
    aux1 = N;


    printf("NOTAS:\n");
    printf("%d nota(s) de R$ 100.00\n",inteiro/100);
    aux = (inteiro%100);
    printf("%d nota(s) de R$ 50.00\n",aux/50);
    aux = (aux%50);
    printf("%d nota(s) de R$ 20.00\n",aux/20);
    aux = (aux%20);
    printf("%d nota(s) de R$ 10.00\n",aux/10);
    aux = (aux%10);
    printf("%d nota(s) de R$ 5.00\n",aux/5);
    aux = (aux%5);
    printf("%d nota(s) de R$ 2.00\n",aux/2);
    aux = (aux%2);

    printf("MOEDAS:\n");
    printf("%d moeda(s) de R$ 1.00\n",aux/1);
    aux1 = aux1%100;
    printf("%d moeda(s) de R$ 0.50\n",aux1/50);
    aux1 = aux1%50;
    printf("%d moeda(s) de R$ 0.25\n",aux1/25);
    aux1 = aux1%25;
    printf("%d moeda(s) de R$ 0.10\n",aux1/10);
    aux1 = aux1%10;
    printf("%d moeda(s) de R$ 0.05\n",aux1/5);
    aux1 = aux1%5;
    printf("%d moeda(s) de R$ 0.01\n",aux1/1);


    return 0;
}

Post a Comment

0 Comments

Ad Code

Responsive Advertisement