結果

問題 No.32 貯金箱の憂鬱
ユーザー yugi0922yugi0922
提出日時 2020-06-28 20:54:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 41 ms / 5,000 ms
コード長 1,414 bytes
コンパイル時間 2,964 ms
コンパイル使用メモリ 74,168 KB
実行使用メモリ 49,772 KB
最終ジャッジ日時 2023-09-30 13:55:44
合計ジャッジ時間 4,100 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
49,116 KB
testcase_01 AC 41 ms
49,196 KB
testcase_02 AC 40 ms
49,364 KB
testcase_03 AC 40 ms
49,208 KB
testcase_04 AC 41 ms
49,376 KB
testcase_05 AC 40 ms
49,772 KB
testcase_06 AC 41 ms
49,296 KB
testcase_07 AC 40 ms
49,208 KB
testcase_08 AC 39 ms
49,200 KB
testcase_09 AC 39 ms
49,324 KB
testcase_10 AC 40 ms
49,280 KB
testcase_11 AC 40 ms
49,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import static java.lang.System.*;

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

public class bankDepression {
	public static void main(String[] args) throws IOException {
		InputStreamReader re = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(new InputStreamReader(in));
		//String[] inputs = reader.readLine().split(" ");
		int hundredCoin = Integer.parseInt(reader.readLine());
		int tfCoin = Integer.parseInt(reader.readLine());
		int oneCoin = Integer.parseInt(reader.readLine());
		if(oneCoin >= 25){
			int changeCount = oneCoinChange(oneCoin);
			oneCoin -= 25 * changeCount;
			tfCoin += changeCount;
		}

		if(tfCoin >= 4){
			int changeCount = tfCoinChange(tfCoin);
			tfCoin -= 4 * changeCount;
			hundredCoin += changeCount;
		}

		if(hundredCoin >= 10){
			int changeCount = hundredCoinChange(hundredCoin);
			hundredCoin -= 10 * changeCount;
		}
		System.out.println(hundredCoin + tfCoin + oneCoin);

	}
	static int oneCoinChange(int oneCoin){
		int count = 0;
		while(oneCoin >= 25){
			oneCoin -= 25;
			count++;
		}
		return count;
	}
	static int tfCoinChange(int tfCoin){
		int count = 0;
		while(tfCoin >= 4){
			tfCoin -= 4;
			count++;
		}
		return count;
	}
	static int hundredCoinChange(int hundredCoin){
		int count = 0;
		while(hundredCoin >= 10){
			hundredCoin -= 10;
			count++;
		}
		return count;
	}

}
0