結果

問題 No.32 貯金箱の憂鬱
ユーザー GchansanjouGchansanjou
提出日時 2018-02-11 15:34:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 43 ms / 5,000 ms
コード長 1,224 bytes
コンパイル時間 3,013 ms
コンパイル使用メモリ 72,564 KB
実行使用メモリ 49,548 KB
最終ジャッジ日時 2023-09-30 13:04:17
合計ジャッジ時間 4,239 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,372 KB
testcase_01 AC 42 ms
49,132 KB
testcase_02 AC 42 ms
49,328 KB
testcase_03 AC 41 ms
49,548 KB
testcase_04 AC 43 ms
49,164 KB
testcase_05 AC 42 ms
49,380 KB
testcase_06 AC 42 ms
49,356 KB
testcase_07 AC 41 ms
49,360 KB
testcase_08 AC 41 ms
49,072 KB
testcase_09 AC 42 ms
49,332 KB
testcase_10 AC 41 ms
49,300 KB
testcase_11 AC 42 ms
49,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukiCoder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class No0032 {

	public static void main(String[] args) {
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

		try {
			int currencyOf100 = Integer.parseInt(bufferedReader.readLine());
			int currencyOf25 = Integer.parseInt(bufferedReader.readLine());
			int currencyOf1 = Integer.parseInt(bufferedReader.readLine());

			int ans = calculation(currencyOf100,currencyOf25,currencyOf1);

			System.out.println(ans);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static int calculation(int currencyOf100, int currencyOf25, int currencyOf1) {
		if (currencyOf100 == 0 && currencyOf25 == 0 && currencyOf1 == 0) {
			return 0;
		}

		if (currencyOf1 > 0) {
			int addcurrencyOf25 = currencyOf1 / 25;
			currencyOf1 = currencyOf1%25;
			currencyOf25 += addcurrencyOf25;
		}
		if (currencyOf25 >= 4) {
			int addCurrencyOf100 = currencyOf25 / 4;
			currencyOf25 = currencyOf25%4;
			currencyOf100 += addCurrencyOf100;
		}
		if (currencyOf100 >= 10) {
			currencyOf100 = currencyOf100%10;
		}
		return currencyOf1 + currencyOf25 + currencyOf100;
	}

}
0