結果

問題 No.207 世界のなんとか
ユーザー UTF-9UTF-9
提出日時 2015-05-31 14:33:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 147 ms / 5,000 ms
コード長 928 bytes
コンパイル時間 2,153 ms
コンパイル使用メモリ 86,280 KB
実行使用メモリ 41,584 KB
最終ジャッジ日時 2024-04-17 16:14:36
合計ジャッジ時間 5,366 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
41,124 KB
testcase_01 AC 116 ms
39,940 KB
testcase_02 AC 134 ms
41,300 KB
testcase_03 AC 117 ms
40,016 KB
testcase_04 AC 112 ms
39,908 KB
testcase_05 AC 122 ms
39,880 KB
testcase_06 AC 121 ms
41,284 KB
testcase_07 AC 132 ms
41,448 KB
testcase_08 AC 124 ms
41,176 KB
testcase_09 AC 132 ms
41,148 KB
testcase_10 AC 147 ms
41,584 KB
testcase_11 AC 123 ms
41,168 KB
testcase_12 AC 132 ms
41,292 KB
testcase_13 AC 127 ms
41,036 KB
testcase_14 AC 127 ms
41,104 KB
testcase_15 AC 127 ms
41,248 KB
testcase_16 AC 126 ms
41,432 KB
testcase_17 AC 124 ms
41,120 KB
testcase_18 AC 132 ms
40,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.util.regex.*;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        ArrayList<Integer> list = new ArrayList<Integer>();
        String regex = "3";
        Pattern p = Pattern.compile(regex);
        for (int i = a; i <= b ; i++) {
            //System.out.println(i);
            if (i % 3 == 0) {
                //System.out.println(i);
                list.add (i);
            } else {
                String str = String.valueOf(i);
                if (p.matcher(str).find()) {
                    list.add(i);
                }
            }
        }
        Collections.sort(list);
        //System.out.println(list);
        for ( int i = 0 ; i < list.size() ; i++ ) {
            System.out.println(list.get(i));
        }
    }
}
0