MC_xjhjdA @ 2024-08-18 11:33:27
def oss(n):
z=[True for _ in range(n+1)]
p=2
while (p*p<=n):
if (z[p]==True):
for i in range(p*p,n+1,p):
z[i]=False
p+=1
zl=[]
for p in range(2,n+1):
if z[p]:
zl.append(p)
return zl
n,q=map(int,input().split())
l=oss(n)
o=[]
for _ in range(q):
o.append(l[int(input())-1])
for x in range(q):
print(o[x])
by _zhang @ 2024-08-25 20:31:05
就只是先用C++AC掉而已(可以去找题解copy借鉴一下),之后你就可以看那个dalao的Py3代码了QWQ
by MC_xjhjdA @ 2024-08-26 18:36:27
@_zhang 知道的 (我来洛谷就玩玩)