結果

問題 No.106 素数が嫌い!2
ユーザー mlihua09mlihua09
提出日時 2020-09-14 02:22:14
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 779 bytes
コンパイル時間 712 ms
コンパイル使用メモリ 86,796 KB
実行使用メモリ 121,556 KB
最終ジャッジ日時 2023-09-04 00:24:46
合計ジャッジ時間 12,895 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #


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

if K > 7:
    print(0)

P = [2, 3, 5, 7, 11, 13]

n = N

for i in range(K - 1):
    n //= P[i]
    
isPrime = [0] + [1] * n

for i in range(2, int(n ** 0.5) + 1):
    if isPrime[i]:
        for j in range(2 * i, n + 1, i):
            isPrime[j] = 0

Prime = [i for i in range(2, n + 1) if isPrime[i]]

ans = 0
n //= P[K - 1]
X = []
for p in Prime:
    x = [p]
    while x[-1] <= n:
        x += [x[-1] * p]
    X += [x]
from itertools import product, combinations
while True:
    z = 0
    for pro in combinations(X, r=K):
        for i in product(*pro):
            y = 1
            for j in i:
                y *= j
            if y <= N:
                z += 1
    if z:
        ans += z
        K += 1
    else:
        break
print(ans)
0