Problem :
Banknotes
Adapted by Neilor Tonin, URI
Brazil
Timelimit: 1
In this problem you have to read an integer number and calculate the smallest possible number of banknotes in which the value may be decomposed. The banknotes possible are 100, 50, 20, 10, 5, 2 e 1. Print the value read and the list of banknotes.
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 in portuguese language like as the given example (with comma as the decimal point). 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 <stdio.h>
int
main() {
int
input , hundred ,fifty , twenty , ten ,five , two ,one ;
scanf
(
"%d"
,&input);
hundred=(input/100);
fifty= (input-(hundred*100))/50;
twenty=(input-((hundred*100)+(fifty*50)))/20;
ten=(input-((twenty*20)+(fifty*50)+(hundred*100)))/10;
five=(input-((ten*10)+(twenty*20)+(fifty*50)+(hundred*100)))/5;
two=(input-((five*5)+(ten*10)+(twenty*20)+(fifty*50)+(hundred*100)))/2;
one=input-((two*2)+(five*5)+(ten*10)+(twenty*20)+(fifty*50)+(hundred*100));
printf
(
"%d\n"
,input);
printf
(
"%d nota(s) de R$ 100,00\n"
,hundred);
printf
(
"%d nota(s) de R$ 50,00\n"
,fifty);
printf
(
"%d nota(s) de R$ 20,00\n"
,twenty);
printf
(
"%d nota(s) de R$ 10,00\n"
,ten);
printf
(
"%d nota(s) de R$ 5,00\n"
,five);
printf
(
"%d nota(s) de R$ 2,00\n"
,two);
printf
(
"%d nota(s) de R$ 1,00\n"
,one);
return
0;
}
No comments:
Post a Comment