結果

問題 No.207 世界のなんとか
ユーザー hhgfhn1
提出日時 2018-08-21 14:52:38
言語 Java
(openjdk 23)
結果
AC  
実行時間 155 ms / 5,000 ms
コード長 864 bytes
コンパイル時間 2,317 ms
コンパイル使用メモリ 76,936 KB
実行使用メモリ 54,368 KB
最終ジャッジ日時 2024-12-15 06:52:42
合計ジャッジ時間 6,098 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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