結果

問題 No.106 素数が嫌い!2
ユーザー ssmkzkssmkzk
提出日時 2019-03-25 23:46:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,776 ms / 5,000 ms
コード長 610 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 97,752 KB
最終ジャッジ日時 2024-04-18 02:13:28
合計ジャッジ時間 22,655 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,526 ms
54,308 KB
testcase_01 AC 35 ms
10,880 KB
testcase_02 AC 37 ms
10,752 KB
testcase_03 AC 35 ms
11,008 KB
testcase_04 AC 1,562 ms
54,392 KB
testcase_05 AC 2,757 ms
97,620 KB
testcase_06 AC 2,514 ms
97,488 KB
testcase_07 AC 2,601 ms
97,620 KB
testcase_08 AC 191 ms
16,528 KB
testcase_09 AC 170 ms
16,928 KB
testcase_10 AC 2,653 ms
97,752 KB
testcase_11 AC 1,115 ms
49,100 KB
testcase_12 AC 2,776 ms
94,020 KB
testcase_13 AC 32 ms
10,880 KB
testcase_14 AC 32 ms
10,880 KB
testcase_15 AC 33 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

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