[URI Online Judge] – 1018 – BankNotes

In this problem you have to read an integer number and calculate the smallest possible number of notes in which the value may be decomposed. The notes are of 100, 50, 20, 10, 5, 2 e 1. Print the value read and the list of notes.

Input

The input file contain an integer number N (0 < N < 1000000).

Output

Print the read number and the minimum quantity of each necessary banknotes, like as the given example. Do not forget to print the end line after each line, otherwise you will get “Presentation Error”.

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

#include <cstdio>

int main(){
int d[] = {100, 50, 20, 10, 5, 2, 1};
int n, t = 0;

scanf(“%d”, &n);
printf(“%d\n”, n);
do {
printf(“%d nota(s) de R$ %d,00\n”, n / d[t], d[t]);
if (n >= d[t])
n -= d[t] * (n / d[t]);
} while(d[t++] != 1);
return 0;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s