結果

問題 No.36 素数が嫌い!
ユーザー tentententen
提出日時 2020-11-17 08:40:57
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 667 bytes
コンパイル時間 2,068 ms
コンパイル使用メモリ 71,212 KB
実行使用メモリ 71,140 KB
最終ジャッジ日時 2023-09-30 07:41:05
合計ジャッジ時間 9,938 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 153 ms
69,032 KB
testcase_01 WA -
testcase_02 AC 135 ms
69,004 KB
testcase_03 AC 142 ms
69,256 KB
testcase_04 AC 142 ms
69,224 KB
testcase_05 AC 204 ms
69,092 KB
testcase_06 AC 206 ms
69,612 KB
testcase_07 AC 207 ms
69,276 KB
testcase_08 AC 153 ms
69,092 KB
testcase_09 AC 150 ms
69,400 KB
testcase_10 AC 162 ms
69,116 KB
testcase_11 AC 252 ms
69,444 KB
testcase_12 AC 335 ms
69,048 KB
testcase_13 AC 336 ms
69,352 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 144 ms
69,544 KB
testcase_17 AC 137 ms
69,128 KB
testcase_18 AC 150 ms
69,160 KB
testcase_19 AC 166 ms
69,112 KB
testcase_20 AC 242 ms
69,052 KB
testcase_21 AC 159 ms
67,276 KB
testcase_22 AC 188 ms
69,276 KB
testcase_23 AC 194 ms
68,988 KB
testcase_24 WA -
testcase_25 AC 153 ms
69,052 KB
testcase_26 AC 281 ms
69,192 KB
testcase_27 AC 314 ms
69,280 KB
testcase_28 AC 291 ms
69,496 KB
testcase_29 AC 330 ms
69,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        boolean[] isNotPrime = new boolean[10000001];
        for (int i = 2; i <= isNotPrime.length && i <= Math.sqrt(n); i++) {
            if (isNotPrime[i]) {
                if (n % i == 0) {
                    System.out.println("YES");
                    return;
                }
            } else {
                for (int j = 2; j * i < isNotPrime.length; j++) {
                    isNotPrime[i * j] = true;
                }
            }
        }
        System.out.print("NO");
    }
}
0