結果

問題 No.36 素数が嫌い!
ユーザー しらっ亭
提出日時 2015-07-29 03:14:39
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 665 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 111,580 KB
最終ジャッジ日時 2024-07-17 21:50:20
合計ジャッジ時間 29,866 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import math


def mark(s, x):
    for i in range(x + x, len(s), x):
        s[i] = False


def sieve(n):
    s = [True] * n
    for x in range(2, int(n ** 0.5) + 1):
        if s[x]:
            mark(s, x)
    return [i for i in range(n) if s[i] and i > 1]


def solve():
    N = int(input())

    rtn = int(math.sqrt(N))

    ps = sieve(rtn + 1)

    ys = []

    i = 0
    while i < len(ps):
        p = ps[i]
        d, m = divmod(N, p)
        if m == 0:
            ys.append(p)
            N = d
        else:
            i += 1
    return len(ys) >= 3


def main():
    print('YES' if solve() else 'NO')


if __name__ == '__main__':
    main()
0