結果

問題 No.106 素数が嫌い!2
ユーザー 12354865271235486527
提出日時 2020-01-14 17:43:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 659 ms / 5,000 ms
コード長 402 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 10,812 KB
実行使用メモリ 57,468 KB
最終ジャッジ日時 2023-08-26 21:32:41
合計ジャッジ時間 7,777 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 401 ms
47,084 KB
testcase_01 AC 143 ms
29,780 KB
testcase_02 AC 144 ms
29,800 KB
testcase_03 AC 145 ms
29,876 KB
testcase_04 AC 397 ms
46,384 KB
testcase_05 AC 650 ms
49,404 KB
testcase_06 AC 639 ms
48,384 KB
testcase_07 AC 646 ms
48,384 KB
testcase_08 AC 184 ms
31,848 KB
testcase_09 AC 183 ms
31,160 KB
testcase_10 AC 659 ms
48,336 KB
testcase_11 AC 361 ms
37,936 KB
testcase_12 AC 659 ms
57,468 KB
testcase_13 AC 144 ms
29,684 KB
testcase_14 AC 143 ms
29,856 KB
testcase_15 AC 144 ms
29,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

def SoE(n):
    if n < 2:
        return
    elif n <= 3:
        return np.arange(2, n+1)
    ret = np.arange(n+1)
    c = int(np.sqrt(n)) + 1
    for i in range(2, c):
        if ret[i] != 0:
            ret[i+i::i] *= 0
    return ret[ret > 1]

N, K = map(int, input().split())
pnl = SoE(N)
nl = np.zeros(N+1)
for pn in pnl:
    nl[pn::pn] += 1
ans = len(nl[nl >= K])
print(ans)
0