結果

問題 No.36 素数が嫌い!
ユーザー しらっ亭しらっ亭
提出日時 2015-07-29 03:14:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 665 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 10,772 KB
実行使用メモリ 109,292 KB
最終ジャッジ日時 2023-09-24 21:25:05
合計ジャッジ時間 26,362 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1,540 ms
87,280 KB
testcase_02 AC 16 ms
8,024 KB
testcase_03 AC 17 ms
8,064 KB
testcase_04 AC 17 ms
8,092 KB
testcase_05 AC 21 ms
8,756 KB
testcase_06 AC 21 ms
8,792 KB
testcase_07 AC 21 ms
8,708 KB
testcase_08 AC 18 ms
8,656 KB
testcase_09 AC 21 ms
8,720 KB
testcase_10 WA -
testcase_11 AC 649 ms
42,052 KB
testcase_12 AC 2,039 ms
109,292 KB
testcase_13 AC 2,043 ms
109,044 KB
testcase_14 AC 1,212 ms
71,716 KB
testcase_15 AC 17 ms
8,092 KB
testcase_16 AC 18 ms
8,016 KB
testcase_17 AC 17 ms
8,088 KB
testcase_18 AC 17 ms
8,120 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 1,048 ms
62,128 KB
testcase_25 WA -
testcase_26 AC 1,231 ms
70,040 KB
testcase_27 AC 1,769 ms
94,948 KB
testcase_28 AC 1,207 ms
68,884 KB
testcase_29 AC 1,969 ms
105,800 KB
権限があれば一括ダウンロードができます

ソースコード

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