結果

問題 No.36 素数が嫌い!
ユーザー shinshin
提出日時 2022-05-18 09:35:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 158 ms / 5,000 ms
コード長 1,104 bytes
コンパイル時間 4,497 ms
コンパイル使用メモリ 75,428 KB
実行使用メモリ 51,960 KB
最終ジャッジ日時 2023-10-14 15:50:34
合計ジャッジ時間 7,907 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
51,480 KB
testcase_01 AC 56 ms
51,396 KB
testcase_02 AC 43 ms
49,376 KB
testcase_03 AC 44 ms
49,428 KB
testcase_04 AC 45 ms
49,904 KB
testcase_05 AC 46 ms
49,360 KB
testcase_06 AC 47 ms
49,344 KB
testcase_07 AC 47 ms
49,404 KB
testcase_08 AC 45 ms
49,472 KB
testcase_09 AC 45 ms
49,408 KB
testcase_10 AC 44 ms
49,332 KB
testcase_11 AC 89 ms
51,512 KB
testcase_12 AC 158 ms
51,480 KB
testcase_13 AC 156 ms
51,616 KB
testcase_14 AC 48 ms
49,408 KB
testcase_15 AC 43 ms
49,240 KB
testcase_16 AC 44 ms
49,616 KB
testcase_17 AC 44 ms
49,420 KB
testcase_18 AC 44 ms
49,380 KB
testcase_19 AC 58 ms
51,552 KB
testcase_20 AC 58 ms
51,756 KB
testcase_21 AC 68 ms
51,960 KB
testcase_22 AC 52 ms
48,272 KB
testcase_23 AC 48 ms
49,480 KB
testcase_24 AC 69 ms
51,548 KB
testcase_25 AC 72 ms
51,604 KB
testcase_26 AC 92 ms
51,304 KB
testcase_27 AC 54 ms
51,648 KB
testcase_28 AC 91 ms
51,316 KB
testcase_29 AC 51 ms
50,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.TreeSet;

public class No36 {
	
	static TreeSet<Long> ts = new TreeSet<>();
	static TreeSet<Long> prime = new TreeSet<>();

	public static void main(String[] args) throws IOException{
		//素数が嫌い!
		long N = Long.parseLong(readStr()[0]);
		
		ts.add(1l);
		wari(N);
		
		System.out.println(ts.size() > prime.size() + 2 ? "YES" : "NO");

	}
	
	public static void wari(long a) {
		int sq = (int)Math.sqrt(a);
		ts.add(a);
		for(int i = 2;i <= Math.max(sq, 3);i++) {
			if(a % i == 0) {
				ts.add((long)i);
				prime.add((long)i);
				ts.add(a / i);
				wari(a / i);
				break;
			}
			if(i == sq) prime.add(a);
		}
	}
	
	public static String[] readStr() throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> list = new ArrayList<>();

		do {
			list.add(br.readLine());
		}while(br.ready());

		br.close();

		String[] text = new String[list.size()];
		list.toArray(text);

		return text;

	}

}
0