import math
if __name__ == '__main__':
n, m = input().split()
s = 1
i = 2
if m == "1":
print("2")
else:
while s < int(n):
if i == 2:
i += 1
s += 1
else:
isPrime = True
for j in range(3, int(math.sqrt(i)) + 1, 2):
if i % j == 0:
isPrime = False
break
if isPrime:
s += 1
i += 2
r = ""
ten = 0
while s <= int(m):
if i == 2:
r += str(i) + " "
i += 1
s += 1
ten += 1
else:
isPrime = True
for j in range(3, int(math.sqrt(i)) + 1, 2):
if i % j == 0:
isPrime = False
break
if isPrime:
s += 1
r += str(i) + " "
ten += 1
if ten % 10 == 0:
r = r[:-1]
r += "\n"
i += 2
print(r[:-1])
PAT (Basic Level) Practice (中文)1013 数素数
最新推荐文章于 2024-11-01 15:19:21 发布