結果

問題 No.106 素数が嫌い!2
ユーザー rpy3cpp
提出日時 2015-07-17 17:50:31
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 490 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 41,984 KB
最終ジャッジ日時 2024-07-08 08:25:31
合計ジャッジ時間 3,975 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(N, K):
    primes = [2, 3, 5, 7, 11, 13, 17, 19]
    if K > len(primes):
        return 0
    pp = 1
    for p in primes[:K]:
        pp *= p
    if pp > N:
        return 0
    ps = [0] * (N + 1)
    for i in range(2, (N + 4)//2):
        if ps[i]:
            continue
        for j in range(i, N + 1, i):
            ps[j] += 1

    count = 0
    for pi in ps[2:]:
        if pi >= K:
            count += 1
    return count

N, K = map(int, input().split())
print(solve(N, K))
0