結果

問題 No.32 貯金箱の憂鬱
ユーザー tsunabittsunabit
提出日時 2018-04-01 00:07:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 5,000 ms
コード長 1,990 bytes
コンパイル時間 4,425 ms
コンパイル使用メモリ 72,084 KB
実行使用メモリ 58,196 KB
最終ジャッジ日時 2023-09-30 13:08:47
合計ジャッジ時間 5,580 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,848 KB
testcase_01 AC 126 ms
55,512 KB
testcase_02 AC 127 ms
55,956 KB
testcase_03 AC 124 ms
58,196 KB
testcase_04 AC 123 ms
55,944 KB
testcase_05 AC 126 ms
56,072 KB
testcase_06 AC 124 ms
56,148 KB
testcase_07 AC 123 ms
56,056 KB
testcase_08 AC 126 ms
55,868 KB
testcase_09 AC 126 ms
55,876 KB
testcase_10 AC 127 ms
55,836 KB
testcase_11 AC 126 ms
55,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

// 問題文
// 太郎君はいつも小銭を貯金していて、硬貨を貯金箱に入れています。
// 貯金箱の中身がある程度たまったので、太郎君は銀行に行って両替をしてもらうことにしました。
// 太郎君の国では通貨として1000円札の紙幣と、100円、25円、1円の硬貨があります。
// それ以外の金額の紙幣や硬貨はありません。
// 両替は、
// ・1円硬貨25枚で25円硬貨1枚に
// ・25円硬貨4枚で100円硬貨1枚に
// ・100円硬貨10枚で1000円札1枚に
// それぞれ替えることができます。
// 入力に、貯金箱の中身としてそれぞれの硬貨の枚数が与えられるので、
// 硬貨の枚数が最も少なくなるように両替したとき、
// 最終的に太郎君が所持する硬貨の合計枚数を出力してください。
// 両替は手数料無く何度でもすることができます。
// また、両替の前後で総額が変化してはいけません。
// 入力
// L
// M
// N
// 1行目に、100円硬貨の枚数を表す整数 L(0≤L≤1000) が与えられます。
// 2行目に、25円硬貨の枚数を表す整数 M(0≤M≤1000) が与えられます。
// 3行目に、1円硬貨の枚数を表す整数 N(0≤N≤1000) が与えられます。
public class No32 {
    public static void main(String[] args) {
        // 標準入力から読み込む際に、Scannerオブジェクトを使う。
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int m = sc.nextInt();
        int n = sc.nextInt();
        int total = (100 * l) + (25 * m) + n;

        int sen = total / 1000;
        total = total - (sen * 1000);
        int hyaku = total / 100;
        total = total - (hyaku * 100);
        int nijugo = total / 25;
        total = total - (nijugo * 25);
        int iti = total;

        System.out.println(hyaku + nijugo + iti);
    }
}
0