結果

問題 No.106 素数が嫌い!2
ユーザー H3PO4H3PO4
提出日時 2020-04-26 14:58:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,167 ms / 5,000 ms
コード長 468 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 75,304 KB
最終ジャッジ日時 2024-04-28 14:28:30
合計ジャッジ時間 15,849 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 790 ms
59,560 KB
testcase_01 AC 457 ms
44,460 KB
testcase_02 AC 452 ms
44,584 KB
testcase_03 AC 461 ms
44,584 KB
testcase_04 AC 807 ms
59,696 KB
testcase_05 AC 1,131 ms
75,272 KB
testcase_06 AC 1,151 ms
75,304 KB
testcase_07 AC 1,126 ms
74,920 KB
testcase_08 AC 498 ms
44,684 KB
testcase_09 AC 488 ms
44,840 KB
testcase_10 AC 1,147 ms
74,896 KB
testcase_11 AC 750 ms
57,260 KB
testcase_12 AC 1,167 ms
74,020 KB
testcase_13 AC 449 ms
44,068 KB
testcase_14 AC 459 ms
44,388 KB
testcase_15 AC 460 ms
44,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

N, K = map(int, input().split())


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return (i for i in range(n + 1) if is_prime[i])


A = np.zeros(N + 1, dtype=int)
for p in primes(N):
    A[p::p] += 1
print(np.count_nonzero(A >= K))
0