結果

問題 No.542 1円玉と5円玉
ユーザー takeya_okinotakeya_okino
提出日時 2017-07-14 22:27:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 644 bytes
コンパイル時間 3,539 ms
コンパイル使用メモリ 85,988 KB
実行使用メモリ 41,992 KB
最終ジャッジ日時 2024-04-16 20:21:51
合計ジャッジ時間 4,527 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
41,568 KB
testcase_01 AC 127 ms
41,588 KB
testcase_02 AC 127 ms
41,408 KB
testcase_03 AC 126 ms
41,436 KB
testcase_04 AC 117 ms
41,532 KB
testcase_05 AC 142 ms
41,596 KB
testcase_06 AC 146 ms
41,888 KB
testcase_07 AC 153 ms
41,844 KB
testcase_08 AC 155 ms
41,784 KB
testcase_09 AC 151 ms
41,992 KB
testcase_10 AC 134 ms
41,800 KB
testcase_11 AC 133 ms
41,552 KB
testcase_12 AC 167 ms
41,956 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