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;
}