結果

問題 No.542 1円玉と5円玉
ユーザー matsuyoshi30matsuyoshi30
提出日時 2018-06-06 23:01:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 695 bytes
コンパイル時間 3,008 ms
コンパイル使用メモリ 75,796 KB
実行使用メモリ 56,128 KB
最終ジャッジ日時 2023-09-12 22:54:59
合計ジャッジ時間 5,675 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,836 KB
testcase_01 AC 126 ms
55,580 KB
testcase_02 AC 127 ms
55,804 KB
testcase_03 AC 128 ms
55,396 KB
testcase_04 AC 129 ms
55,584 KB
testcase_05 AC 147 ms
56,004 KB
testcase_06 AC 148 ms
56,128 KB
testcase_07 AC 159 ms
55,740 KB
testcase_08 AC 161 ms
55,732 KB
testcase_09 AC 160 ms
55,728 KB
testcase_10 AC 129 ms
56,032 KB
testcase_11 AC 133 ms
55,764 KB
testcase_12 AC 179 ms
55,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();

        HashSet<Integer> set = new HashSet<>();

        for(int i=0; i<=a; i++) {
            for(int j=0; j<=b; j++) {
                if(i != 0 || j != 0)
                    set.add(i + j*5);
            }
        }

        ArrayList<Integer> list = new ArrayList<>();
        Iterator<Integer> it = set.iterator();

        while(it.hasNext())
            list.add(it.next());

        Collections.sort(list);

        for(int i=0; i<list.size(); i++)
            System.out.println(list.get(i));
    }
}
0