結果
問題 | No.36 素数が嫌い! |
ユーザー | ぴろず |
提出日時 | 2014-12-16 21:42:19 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,593 bytes |
コンパイル時間 | 3,787 ms |
コンパイル使用メモリ | 75,000 KB |
実行使用メモリ | 81,620 KB |
最終ジャッジ日時 | 2023-09-02 15:22:18 |
合計ジャッジ時間 | 11,985 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 280 ms
75,176 KB |
testcase_02 | AC | 126 ms
42,700 KB |
testcase_03 | AC | 121 ms
39,492 KB |
testcase_04 | AC | 124 ms
39,884 KB |
testcase_05 | AC | 123 ms
39,572 KB |
testcase_06 | AC | 126 ms
39,548 KB |
testcase_07 | AC | 127 ms
39,492 KB |
testcase_08 | AC | 128 ms
40,248 KB |
testcase_09 | AC | 128 ms
39,784 KB |
testcase_10 | WA | - |
testcase_11 | AC | 202 ms
50,456 KB |
testcase_12 | AC | 325 ms
67,456 KB |
testcase_13 | AC | 309 ms
79,940 KB |
testcase_14 | AC | 243 ms
71,800 KB |
testcase_15 | AC | 124 ms
55,832 KB |
testcase_16 | AC | 125 ms
55,500 KB |
testcase_17 | AC | 123 ms
55,440 KB |
testcase_18 | AC | 122 ms
55,824 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 245 ms
67,088 KB |
testcase_25 | WA | - |
testcase_26 | AC | 240 ms
71,336 KB |
testcase_27 | AC | 305 ms
81,620 KB |
testcase_28 | AC | 239 ms
69,788 KB |
testcase_29 | AC | 300 ms
79,712 KB |
ソースコード
package no036; import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); SeiveOfEratosthenes.init(n+1); if (SeiveOfEratosthenes.primeFactor(n).size() >= 3) { System.out.println("YES"); }else{ System.out.println("NO"); } } } class SeiveOfEratosthenes { private static long max_number; private static int max_number_sieve; private static boolean[] is_not_prime; private static ArrayList<Integer> prime = new ArrayList<Integer>(); public static void init(long maxnum) { max_number = maxnum; max_number_sieve = (int) Math.sqrt(max_number); is_not_prime = new boolean[max_number_sieve+1]; is_not_prime[0] = is_not_prime[1] = true; for(int i=2;i*i<=max_number_sieve;i++) { if (!is_not_prime[i]) { int j = 2; while(i*j<=max_number_sieve) { is_not_prime[i*j] = true; j++; } } } for(int i=2;i<=max_number_sieve;i++) { if(!is_not_prime[i]) { prime.add(i); } } } public static boolean isPrime(long n) { if (n>max_number) { return false; } if (n<=max_number_sieve) { return !is_not_prime[(int) n]; }else{ for(int p:prime) { if (n%p==0 && n!=p) { return false; } } return true; } } public static ArrayList<Integer> primeFactor(long n) { ArrayList<Integer> factor = new ArrayList<Integer>(); for(int p:prime) { while(n%p==0) { n/=p; factor.add(p); } } return factor; } }