結果

問題 No.207 世界のなんとか
ユーザー hhgfhn1hhgfhn1
提出日時 2018-08-21 14:52:38
言語 Java19
(openjdk 21)
結果
AC  
実行時間 138 ms / 5,000 ms
コード長 864 bytes
コンパイル時間 2,383 ms
コンパイル使用メモリ 75,072 KB
実行使用メモリ 56,168 KB
最終ジャッジ日時 2023-08-21 17:20:32
合計ジャッジ時間 5,987 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,804 KB
testcase_01 AC 120 ms
55,816 KB
testcase_02 AC 136 ms
55,588 KB
testcase_03 AC 132 ms
55,788 KB
testcase_04 AC 128 ms
55,616 KB
testcase_05 AC 136 ms
55,852 KB
testcase_06 AC 122 ms
55,932 KB
testcase_07 AC 118 ms
56,168 KB
testcase_08 AC 118 ms
55,576 KB
testcase_09 AC 136 ms
56,072 KB
testcase_10 AC 135 ms
56,064 KB
testcase_11 AC 135 ms
55,876 KB
testcase_12 AC 138 ms
55,812 KB
testcase_13 AC 137 ms
55,444 KB
testcase_14 AC 138 ms
55,716 KB
testcase_15 AC 137 ms
55,592 KB
testcase_16 AC 120 ms
55,996 KB
testcase_17 AC 116 ms
55,940 KB
testcase_18 AC 119 ms
55,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class sampleA {
	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int min = scan.nextInt();
		int max = scan.nextInt();
		List<Integer> answers = new ArrayList<>();

		for (int i = min; i <= max; i++) {
			if (judge(i, answers)) {
				answers.add(i);
			}
		}
		
		for (int answer : answers) {
			System.out.println(answer);
		}

	}

	private static boolean judge(int i, List<Integer> answers) {
		// TODO 自動生成されたメソッド・スタブ
		Pattern p = Pattern.compile("^[0-9]*3+[0-9]*$");
		Matcher m = p.matcher(String.valueOf(i));

		if (i % 3 == 0 || m.find() && !answers.contains(i)) {
			return true;
		} else {
			return false;
		}
	}
}
0