結果

問題 No.32 貯金箱の憂鬱
ユーザー monburan_0401monburan_0401
提出日時 2018-08-27 10:10:26
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 1,402 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 27,532 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 13:14:05
合計ジャッジ時間 768 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 0 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*	太郎君の国では通貨として1000円札の紙幣と、100円、25円、1円の硬貨があります。
それ以外の金額の紙幣や硬貨はありません。
両替は、
・1円硬貨25枚で25円硬貨1枚に
・25円硬貨4枚で100円硬貨1枚に
・100円硬貨10枚で1000円札1枚に
それぞれ替えることができます。
入力に、貯金箱の中身としてそれぞれの硬貨の枚数が与えられるので、
硬貨の枚数が最も少なくなるように両替したとき、
最終的に太郎君が所持する硬貨の合計枚数を出力してください。
両替は手数料無く何度でもすることができます。
また、両替の前後で総額が変化してはいけません。*/
#include<stdio.h>
int main(void){
	int money[4] = {1000, 100, 25, 1};
	int L,M,N;		//	100円硬貨、25円硬貨、1円硬貨の順で入力
	int change;		//	両替の際に使う
	scanf("%d",&L);
	scanf("%d",&M);
	scanf("%d",&N);
	//printf("100円%d枚、25円%d枚、1円%d枚\n",L,M,N);
	
	change = N / 25;
	M += change;
	N -= change * 25;
	//printf("100円%d枚、25円%d枚、1円%d枚\n",L,M,N);
	
	change = M  / 4;
	L += change;
	M -= change * 4;
	//printf("100円%d枚、25円%d枚、1円%d枚\n",L,M,N);
	
	change = L  / 10;
	L -= change * 10;
	//printf("100円%d枚、25円%d枚、1円%d枚\n",L,M,N);
	
	printf("%d\n",L + M + N);
	return 0;
}
0