結果

問題 No.36 素数が嫌い!
ユーザー tora3kuma3tora3kuma3
提出日時 2015-04-19 09:17:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 552 bytes
コンパイル時間 367 ms
コンパイル使用メモリ 10,888 KB
実行使用メモリ 83,852 KB
最終ジャッジ日時 2023-09-18 00:30:29
合計ジャッジ時間 20,470 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 643 ms
43,416 KB
testcase_01 AC 1,136 ms
67,112 KB
testcase_02 AC 16 ms
8,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 20 ms
8,512 KB
testcase_08 AC 17 ms
8,428 KB
testcase_09 AC 18 ms
8,432 KB
testcase_10 AC 18 ms
8,456 KB
testcase_11 AC 551 ms
32,892 KB
testcase_12 AC 1,787 ms
83,852 KB
testcase_13 WA -
testcase_14 AC 895 ms
55,048 KB
testcase_15 AC 16 ms
8,356 KB
testcase_16 AC 17 ms
8,476 KB
testcase_17 AC 17 ms
8,144 KB
testcase_18 AC 16 ms
8,384 KB
testcase_19 AC 544 ms
37,704 KB
testcase_20 AC 1,441 ms
83,764 KB
testcase_21 AC 1,119 ms
65,796 KB
testcase_22 AC 1,153 ms
67,580 KB
testcase_23 AC 681 ms
43,964 KB
testcase_24 AC 753 ms
48,032 KB
testcase_25 AC 729 ms
47,456 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
from itertools import compress, count
readline = stdin.readline


def sieve(n):
    p = [1] * (n + 1)
    p[0] = p[1] = 0

    for i in range(int(n ** 0.5) + 1):
        if p[i]:
            for j in range(2 * i, len(p), i):
                p[j] = 0
    return p


def isnotprime(n):
    p = sieve(int(n ** 0.5))

    for i in compress(count(), p):
        if n % i == 0:
            return True
    return False


def solve(n):
    print('YES' if isnotprime(n) else 'NO')


def main():
    n = int(readline())
    solve(n)
main()
0