結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1,254 ms
67,132 KB
testcase_02 AC 17 ms
8,496 KB
testcase_03 AC 17 ms
8,564 KB
testcase_04 AC 17 ms
8,560 KB
testcase_05 AC 19 ms
8,440 KB
testcase_06 AC 20 ms
8,488 KB
testcase_07 AC 20 ms
8,536 KB
testcase_08 AC 17 ms
8,488 KB
testcase_09 AC 19 ms
8,484 KB
testcase_10 WA -
testcase_11 AC 581 ms
32,816 KB
testcase_12 AC 1,794 ms
83,612 KB
testcase_13 AC 1,703 ms
83,632 KB
testcase_14 AC 854 ms
55,004 KB
testcase_15 AC 17 ms
8,420 KB
testcase_16 AC 16 ms
8,472 KB
testcase_17 AC 16 ms
8,132 KB
testcase_18 AC 16 ms
8,496 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 774 ms
47,824 KB
testcase_25 WA -
testcase_26 AC 1,019 ms
54,028 KB
testcase_27 AC 1,460 ms
72,892 KB
testcase_28 AC 995 ms
53,308 KB
testcase_29 AC 1,662 ms
81,060 KB
権限があれば一括ダウンロードができます

ソースコード

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 is_dividable_nonprime(n):
    p = sieve(int(n ** 0.5))

    cnt = 0
    for i in compress(count(), p):
        while n % i == 0:
            cnt += 1
            n //= i
            if cnt == 3:
                return True
    return False


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


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