結果

問題 No.32 貯金箱の憂鬱
ユーザー sasa
提出日時 2025-03-03 14:36:35
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 620 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 28,416 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-03-03 14:36:36
合計ジャッジ時間 1,068 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4 WA * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%d",&coin100);
      |         ~~~~~^~~~~~~~~~~~~~~
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         scanf("%d",&coin25);
      |         ~~~~~^~~~~~~~~~~~~~
main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         scanf("%d",&coin1);
      |         ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

int main(void){
	// 100円硬貨の枚数
	int coin100 = 0;
	scanf("%d",&coin100);
	// 25円硬貨の枚数
	int coin25 = 0;
	scanf("%d",&coin25);
	// 1円硬貨の枚数
	int coin1 = 0;
	scanf("%d",&coin1);
	// 1円硬貨を25円硬貨に両替
	coin25 += (coin1 / 25);
	if((coin1 / 25) > 0){
		coin1 = (coin1 % 25);		
	}
	// 25円硬貨を100円硬貨に両替
	coin100 += (coin25 / 4);
	if((coin25 / 4) > 0){
		coin25 = (coin1 % 4);	
	}
	// 100円硬貨を1000円紙幣に両替
	if((coin100 / 10) > 0){
		coin100 = (coin100 % 10);	
	}
	printf("%d",coin100 + coin25 + coin1);
}
0