結果

問題 No.106 素数が嫌い!2
ユーザー ssmkzkssmkzk
提出日時 2019-03-25 23:41:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 609 bytes
コンパイル時間 119 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 98,800 KB
最終ジャッジ日時 2024-04-18 02:05:08
合計ジャッジ時間 17,731 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2,472 ms
97,624 KB
testcase_08 WA -
testcase_09 AC 166 ms
17,060 KB
testcase_10 AC 2,239 ms
97,496 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 31 ms
10,880 KB
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def SoE(x):
    if x < 2:
        return []
    
    l = [i for i in range(x + 1)]
    l[1] = 0
    
    for i in l:
        if i > math.sqrt(x):
            break
        if i == 0:
            continue
        for j in range(2 * i , x + 1, i):
            l[j] = 0
    
    return [i for i in l if i != 0]

prime_l = SoE(N)

l = [0 for i in range(N + 1)]

for li in prime_l:
    ck = li
    while ck <= N:
        l[ck] += 1
        ck += li

l.sort()
l.reverse()

count = 0

for li in l:
    if li > K:
        count += 1
    else:
        break

print(count)
0