結果

問題 No.32 貯金箱の憂鬱
コンテスト
ユーザー bigbear90560
提出日時 2015-07-03 00:36:57
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 55 ms / 5,000 ms
コード長 984 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,057 ms
コンパイル使用メモリ 82,064 KB
実行使用メモリ 41,696 KB
最終ジャッジ日時 2026-04-03 12:06:29
合計ジャッジ時間 3,788 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.Scanner;

/**
 * No.32 貯金箱の憂鬱
 */
public class MelancholyOfPiggyBank {

	public static void main(String[] args) {

        // 標準入力から読み込む際に、Scannerオブジェクトを使う。
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();	// 100円
        int b = sc.nextInt();	//  25円
        int c = sc.nextInt();	//   1円

        int upCoinNum = 0;
        int restCoinNum = 0;
        int sumCoinNum = 0;
        
        if (0 != c) {
        	upCoinNum = (int)Math.floor(c / 25);
        	restCoinNum = c % 25;
        	b += upCoinNum;
        	sumCoinNum += restCoinNum; 
        }
        if (0 != b) {
        	upCoinNum = (int)Math.floor((b)/ 4);
        	restCoinNum = b % 4;
        	a += upCoinNum;
        	sumCoinNum += restCoinNum; 
        }
        if (0 != a) {
        	restCoinNum = a % 10;
        	sumCoinNum += restCoinNum; 
        }
        System.out.println(sumCoinNum);
	}

}
0