-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path047.py
More file actions
34 lines (25 loc) · 671 Bytes
/
047.py
File metadata and controls
34 lines (25 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def primes_sieve2(limit):
a = [True] * limit
factors = [0] * limit
a[0] = a[1] = False
for (i, isprime) in enumerate(a):
if isprime:
for n in range(2 * i, limit, i):
a[n] = False
factors[n] = factors[n] + 1
return factors
numbers = numbers = list(map(int, input().split()))
N = numbers[0]
K = numbers[1]
flag = [False] * (N + K)
prime_factors = primes_sieve2(N + K)
for i in range(2, N + K):
flag[i] = (prime_factors[i] == K)
for i in range(2, N + 1):
pri = True
for j in range(i, i + K):
pri = flag[j]
if not pri:
break
if pri:
print(i)