結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 629 ms
43,312 KB
testcase_01 AC 1,084 ms
67,004 KB
testcase_02 AC 16 ms
8,424 KB
testcase_03 AC 16 ms
8,440 KB
testcase_04 WA -
testcase_05 AC 19 ms
8,456 KB
testcase_06 AC 19 ms
8,456 KB
testcase_07 AC 19 ms
8,468 KB
testcase_08 AC 17 ms
8,508 KB
testcase_09 AC 18 ms
8,492 KB
testcase_10 AC 17 ms
8,488 KB
testcase_11 AC 539 ms
32,876 KB
testcase_12 AC 1,693 ms
83,952 KB
testcase_13 WA -
testcase_14 AC 870 ms
55,044 KB
testcase_15 AC 16 ms
8,428 KB
testcase_16 AC 16 ms
8,428 KB
testcase_17 AC 17 ms
8,268 KB
testcase_18 AC 16 ms
8,444 KB
testcase_19 AC 531 ms
37,588 KB
testcase_20 AC 1,430 ms
83,660 KB
testcase_21 AC 1,062 ms
66,044 KB
testcase_22 AC 1,117 ms
67,888 KB
testcase_23 AC 642 ms
43,808 KB
testcase_24 AC 778 ms
47,916 KB
testcase_25 AC 706 ms
47,520 KB
testcase_26 AC 1,026 ms
54,056 KB
testcase_27 AC 1,463 ms
72,952 KB
testcase_28 AC 994 ms
53,268 KB
testcase_29 AC 1,666 ms
81,100 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 == 2:
                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