結果

問題 No.542 1円玉と5円玉
ユーザー takeya_okinotakeya_okino
提出日時 2017-07-14 22:27:28
言語 Java19
(openjdk 21)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 644 bytes
コンパイル時間 3,732 ms
コンパイル使用メモリ 73,592 KB
実行使用メモリ 56,276 KB
最終ジャッジ日時 2023-07-29 14:29:25
合計ジャッジ時間 5,008 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,888 KB
testcase_01 AC 124 ms
55,996 KB
testcase_02 AC 122 ms
56,088 KB
testcase_03 AC 122 ms
55,740 KB
testcase_04 AC 123 ms
55,684 KB
testcase_05 AC 142 ms
55,576 KB
testcase_06 AC 146 ms
55,872 KB
testcase_07 AC 147 ms
56,124 KB
testcase_08 AC 147 ms
55,824 KB
testcase_09 AC 161 ms
55,824 KB
testcase_10 AC 129 ms
55,908 KB
testcase_11 AC 134 ms
55,868 KB
testcase_12 AC 181 ms
56,276 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();
    HashSet<Integer> set = new HashSet<Integer>();
    for(int i = 0; i <= a; i++) {
      for(int j = 0; j <= b; j++) {
        if((i != 0) || (j != 0)) set.add(i + 5 * j);
      }
    }
    ArrayList<Integer> list = new ArrayList<Integer>();
    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