結果

問題 No.106 素数が嫌い!2
ユーザー 双六双六
提出日時 2020-07-22 14:04:22
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 859 bytes
コンパイル時間 1,441 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 108,380 KB
最終ジャッジ日時 2023-09-02 12:00:54
合計ジャッジ時間 12,967 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 #

import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))


num = 2 * 10 ** 6 + 1 
L = [1 for i in range(num)]; L[0] = 0; L[1] = 0
plist = []
for i in range(num):
	if L[i] == 1:
		plist.append(i); c = 2
		while i * c <= num - 1:
			L[i * c] = 0; c += 1

#素因数分解の結果を辞書型として返す
def prime_factorization(N):
	D = defaultdict(int)
	for i in plist:
		while N % i == 0:
			D[i] += 1; N = int(N // i)

	#num以上の素数が含まれているケースの処理
	if N != 1:
		D[N] += 1

	return D

#処理内容
def main():
	N, K = getlist()
	ans = 0
	for i in range(2, N + 1):
		fac = prime_factorization(i)
		if len(fac) >= K:
			ans += 1

	print(ans)

if __name__ == '__main__':
	main()
0