結果

問題 No.106 素数が嫌い!2
ユーザー brthyyjpbrthyyjp
提出日時 2021-06-02 20:11:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 497 ms / 5,000 ms
コード長 454 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 82,532 KB
実行使用メモリ 83,260 KB
最終ジャッジ日時 2024-04-27 13:34:03
合計ジャッジ時間 5,268 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 278 ms
78,796 KB
testcase_01 AC 90 ms
75,760 KB
testcase_02 AC 92 ms
76,028 KB
testcase_03 AC 94 ms
76,740 KB
testcase_04 AC 287 ms
79,264 KB
testcase_05 AC 474 ms
81,624 KB
testcase_06 AC 497 ms
83,260 KB
testcase_07 AC 483 ms
78,840 KB
testcase_08 AC 122 ms
79,604 KB
testcase_09 AC 131 ms
79,012 KB
testcase_10 AC 494 ms
78,556 KB
testcase_11 AC 269 ms
82,196 KB
testcase_12 AC 471 ms
78,576 KB
testcase_13 AC 88 ms
75,828 KB
testcase_14 AC 87 ms
75,588 KB
testcase_15 AC 103 ms
77,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

N = 2*10**6+50
spf = [-1]*(N+1)
for i in range(N+1):
    spf[i] = i
for i in range(2, int(math.sqrt(N))+1):
    if spf[i] == i:
        for j in range(i*2, N+1, i):
            if spf[j] == j:
                spf[j] = i

n, k = map(int, input().split())
ans = 0
for i in range(1, n+1):
    cnt = 0
    while i != 1:
        p = spf[i]
        cnt += 1
        while i%p == 0:
            i //= p
    if cnt >= k:
        ans += 1
print(ans)
0