結果

問題 No.32 貯金箱の憂鬱
ユーザー l1267976l1267976
提出日時 2017-03-07 18:37:25
言語 Java19
(openjdk 21)
結果
AC  
実行時間 125 ms / 5,000 ms
コード長 657 bytes
コンパイル時間 3,220 ms
コンパイル使用メモリ 72,732 KB
実行使用メモリ 55,932 KB
最終ジャッジ日時 2023-09-30 08:24:28
合計ジャッジ時間 5,651 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,800 KB
testcase_01 AC 125 ms
55,652 KB
testcase_02 AC 124 ms
55,584 KB
testcase_03 AC 124 ms
55,860 KB
testcase_04 AC 122 ms
55,832 KB
testcase_05 AC 124 ms
55,452 KB
testcase_06 AC 125 ms
55,636 KB
testcase_07 AC 123 ms
55,932 KB
testcase_08 AC 124 ms
55,904 KB
testcase_09 AC 122 ms
55,752 KB
testcase_10 AC 123 ms
55,688 KB
testcase_11 AC 122 ms
55,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No32 {

    public static void main(String[] args) {
        int[] coins = { 1000, 100, 25, 1 };

        Scanner sc = new Scanner(System.in);
        int sum = 0;
        for (int i = 1; i <= 3; i++) {
            sum += sc.nextInt() * coins[i];
        }

        int[] coinsCnt = new int[4];

        for (int i = 0; i < coins.length; i++) {
            coinsCnt[i] = sum / coins[i];
            sum -= coins[i] * coinsCnt[i];
        }

        int result = 0;

        for (int i = 1; i <= 3; i++) {
            result += coinsCnt[i];
        }

        System.out.println(result);

        sc.close();
    }

}
0