結果

問題 No.542 1円玉と5円玉
ユーザー htensaihtensai
提出日時 2019-12-07 17:09:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 639 bytes
コンパイル時間 2,815 ms
コンパイル使用メモリ 73,680 KB
実行使用メモリ 56,588 KB
最終ジャッジ日時 2023-08-26 21:33:19
合計ジャッジ時間 5,224 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
55,956 KB
testcase_01 AC 114 ms
56,036 KB
testcase_02 AC 112 ms
56,236 KB
testcase_03 AC 115 ms
56,200 KB
testcase_04 AC 111 ms
56,312 KB
testcase_05 AC 119 ms
56,588 KB
testcase_06 AC 119 ms
55,684 KB
testcase_07 AC 120 ms
56,308 KB
testcase_08 AC 120 ms
56,588 KB
testcase_09 AC 118 ms
56,220 KB
testcase_10 AC 112 ms
56,208 KB
testcase_11 AC 115 ms
56,380 KB
testcase_12 AC 131 ms
55,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        TreeSet<Integer> set = new TreeSet<>();
        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                if (i == 0 && j == 0){
                    continue;
                }
                set.add(i * 1 + j * 5);
            }
        }
        StringBuilder sb = new StringBuilder();
        for (Integer x : set) {
            sb.append(x).append("\n");
        }
        System.out.print(sb);
    }
}
0