結果

問題 No.36 素数が嫌い!
ユーザー tora3kuma3tora3kuma3
提出日時 2015-04-19 10:14:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,790 ms / 5,000 ms
コード長 721 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 83,972 KB
最終ジャッジ日時 2023-09-09 07:10:30
合計ジャッジ時間 16,888 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
43,308 KB
testcase_01 AC 1,070 ms
66,940 KB
testcase_02 AC 16 ms
8,372 KB
testcase_03 AC 16 ms
8,464 KB
testcase_04 AC 16 ms
8,436 KB
testcase_05 AC 19 ms
8,520 KB
testcase_06 AC 20 ms
8,440 KB
testcase_07 AC 19 ms
8,476 KB
testcase_08 AC 16 ms
8,548 KB
testcase_09 AC 16 ms
8,532 KB
testcase_10 AC 17 ms
8,456 KB
testcase_11 AC 552 ms
32,780 KB
testcase_12 AC 1,780 ms
83,972 KB
testcase_13 AC 1,790 ms
83,640 KB
testcase_14 AC 836 ms
55,080 KB
testcase_15 AC 16 ms
8,272 KB
testcase_16 AC 16 ms
8,340 KB
testcase_17 AC 16 ms
8,232 KB
testcase_18 AC 16 ms
8,476 KB
testcase_19 AC 268 ms
37,732 KB
testcase_20 AC 1,380 ms
83,568 KB
testcase_21 AC 364 ms
65,940 KB
testcase_22 AC 559 ms
67,696 KB
testcase_23 AC 511 ms
43,932 KB
testcase_24 AC 782 ms
47,892 KB
testcase_25 AC 113 ms
47,264 KB
testcase_26 AC 1,060 ms
53,952 KB
testcase_27 AC 1,519 ms
72,852 KB
testcase_28 AC 1,041 ms
53,108 KB
testcase_29 AC 1,741 ms
81,092 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]:
            yield i
            for j in range(2 * i, len(p), i):
                p[j] = 0
    for i in range(int(n ** 0.5) + 1, len(p)):
        if p[i]:
            yield i

def is_dividable_nonprime(n):
    cnt = 0
    for i in sieve(int(n ** 0.5)):
        while n % i == 0:
            cnt += 1
            n //= i
            if cnt == 2:
                return n != 1
    return False


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


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