結果

問題 No.542 1円玉と5円玉
ユーザー mosmos_21
提出日時 2017-07-15 18:23:03
言語 Java
(openjdk 23)
結果
AC  
実行時間 184 ms / 2,000 ms
コード長 729 bytes
コンパイル時間 3,004 ms
コンパイル使用メモリ 76,568 KB
実行使用メモリ 54,328 KB
最終ジャッジ日時 2024-10-08 02:32:02
合計ジャッジ時間 5,670 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    Scanner in = new Scanner(System.in);

    public void solve() {
        int a = in.nextInt(), b = in.nextInt();
        HashSet<Integer> set = new HashSet<>();

        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                set.add(i + j * 5);
            }
        }
        Integer[] list = new Integer[set.size()];
        set.toArray(list);
        Arrays.sort(list);
        for (int i = 0; i < list.length; i++) {
            if (list[i] != 0)
                System.out.println(list[i]);
        }
    }

    public static void main(String[] args) {
        new Main().solve();
    }
}
0