結果

問題 No.36 素数が嫌い!
ユーザー n3k2t1n3k2t1
提出日時 2019-07-21 20:30:32
言語 JavaScript
(node v21.7.1)
結果
RE  
実行時間 -
コード長 578 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 6,944 KB
実行使用メモリ 40,448 KB
最終ジャッジ日時 2024-04-21 02:50:03
合計ジャッジ時間 11,001 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 62 ms
39,680 KB
testcase_03 AC 64 ms
39,296 KB
testcase_04 AC 62 ms
39,424 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

const lines = require('fs').readFileSync('/dev/stdin', 'utf-8')
    .trim().split(' ').values();

const N = Number(lines.next().value);

if (N == 1) {
    console.log('NO');
    return;
}

const primes = Array(N + 1).fill(true);

primes[0] = false;
primes[1] = false;

for (let i = 2; i <= Math.sqrt(N); i++) {
    if (primes[i]) {
        for (let j = i + i; j <= N; j += i) {
            primes[j] = false;
        }
    }
}

for (let i = 2; i <= Math.sqrt(N); i++) {
    if (N % i === 0 && !primes[i]) {
        console.log('YES');
        return;
    }
}

console.log('NO');
0