653.钞票
在这个问题中,你需要读取一个整数值并将其分解为多张钞票的和,每种面值的钞票可以使用多张,并要求所用的钞票数量尽可能少。
请你输出读取值和钞票清单。
钞票的可能面值有100,50,20,10,5,2,1。
输入格式
输入一个整数N。
输出格式
参照输出样例,输出读取数值以及每种面值的钞票的需求数量。
数据范围
0<N<1000000
输入样例:
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
/* 这题因为最小面值是1,所以直接从大到小除就完事儿了,
或者不用写这么长,直接每次令 n = n % 上一个面值即可
最小不是1就直接用循环*/
#include <cstdio>
#include <cmath>
int main()
{
int n;
scanf("%d", &n);
printf("%d\n", n);
printf("%d nota(s) de R$ 100,00\n", n / 100);
printf("%d nota(s) de R$ 50,00\n", n % 100 / 50);
printf("%d nota(s) de R$ 20,00\n", n % 100 % 50 / 20);
printf("%d nota(s) de R$ 10,00\n", n % 100 % 50 % 20 / 10);
printf("%d nota(s) de R$ 5,00\n", n % 100 % 50 % 20 % 10 / 5);
printf("%d nota(s) de R$ 2,00\n", n % 100 % 50 % 20 % 10 % 5 / 2);
printf("%d nota(s) de R$ 1,00\n", n % 100 % 50 % 20 % 10 % 5 % 2);
return 0;
}