結果

問題 No.106 素数が嫌い!2
ユーザー roarisroaris
提出日時 2019-12-20 00:58:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 229 ms / 5,000 ms
コード長 528 bytes
コンパイル時間 376 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 118,660 KB
最終ジャッジ日時 2023-09-21 07:53:24
合計ジャッジ時間 3,501 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
97,004 KB
testcase_01 AC 80 ms
71,652 KB
testcase_02 AC 74 ms
71,660 KB
testcase_03 AC 74 ms
71,640 KB
testcase_04 AC 149 ms
96,996 KB
testcase_05 AC 229 ms
118,248 KB
testcase_06 AC 223 ms
118,660 KB
testcase_07 AC 218 ms
118,304 KB
testcase_08 AC 91 ms
78,696 KB
testcase_09 AC 90 ms
78,828 KB
testcase_10 AC 212 ms
118,280 KB
testcase_11 AC 139 ms
94,380 KB
testcase_12 AC 226 ms
115,768 KB
testcase_13 AC 73 ms
71,588 KB
testcase_14 AC 73 ms
71,632 KB
testcase_15 AC 79 ms
76,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def era(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(2*i, n+1, i):
            is_prime[j] = False
    
    return [i for i in range(n+1) if is_prime[i]]

N, K = map(int, input().split())
cnt = [0]*(1+N)
primes = era(N)

for p in primes:
    for i in range(p, N+1, p):
        cnt[i] += 1

ans = 0

for i in range(2, N+1):
    if cnt[i]>=K:
        ans += 1

print(ans)
0