0
点赞
收藏
分享

微信扫一扫

653. 钞票


文章目录

  • ​​Question​​
  • ​​Ideas​​
  • ​​Code​​

Question

在这个问题中,你需要读取一个整数值并将其分解为多张钞票的和,每种面值的钞票可以使用多张,并要求所用的钞票数量尽可能少。

请你输出读取值和钞票清单。

钞票的可能面值有 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
难度:中等
时/空限制:1s / 64MB
总通过数:15618
总尝试数:39420
来源:语法题
算法标签

Ideas

Code

#include <iostream>

using namespace std;

int main()
{
int n;
cin >> n;
cout << n << endl;
printf("%d nota(s) de R$ 100,00\n",n/100);
n = n - n / 100 * 100;
printf("%d nota(s) de R$ 50,00\n", n/50);
n = n - n / 50 * 50;
printf("%d nota(s) de R$ 20,00\n", n/20);
n = n - n / 20 * 20;
printf("%d nota(s) de R$ 10,00\n", n/10);
n = n - n / 10 * 10;
printf("%d nota(s) de R$ 5,00\n", n/5);
n = n - n / 5 * 5;
printf("%d nota(s) de R$ 2,00\n", n/2);
n = n - n / 2 * 2;
printf("%d nota(s) de R$ 1,00\n", n);

return 0;

}


举报

相关推荐

0 条评论