結果

問題 No.36 素数が嫌い!
コンテスト
ユーザー しらっ亭
提出日時 2015-07-29 03:01:45
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 646 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 428 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 227,624 KB
最終ジャッジ日時 2026-04-01 12:47:52
合計ジャッジ時間 23,319 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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)

    for p in ps:
        d, m = divmod(N, p)
        if m == 0:
            i = bisect.bisect_left(ps, d)
            if i >= len(ps) or ps[i] != d:
                return True
    return False


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


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