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-23 10:58:38
@MC_xjhjdA 不太懂Python分不分输入输出流,不过C++是分的
by _zhang @ 2024-08-23 11:31:42
@MC_xjhjdA 重大消息!那个AC的Py巨佬用的是numpy,你要重构代码了
by MC_xjhjdA @ 2024-08-23 12:00:48
@_zhang XD用numpy没有思路,因为我不怎么会用
by _zhang @ 2024-08-23 12:29:08
@MC_xjhjdA 我也不会numpy库,好好用C++他不香吗
by _zhang @ 2024-08-23 12:29:47
你可以先用C++过一遍就能看到他的代码了
by MC_xjhjdA @ 2024-08-23 12:58:02
@_zhang 呃啊不会 难不成我要copy题解
by _zhang @ 2024-08-23 14:52:06
@MC_xjhjdA 你说你不会C++,只会Python?
by _zhang @ 2024-08-23 14:53:35
你用其他不怎么占时间空间的语言也行,Python的常数实在太大了
by MC_xjhjdA @ 2024-08-25 02:03:38
@_zhang 确实不会c++只会python3XD
by _zhang @ 2024-08-25 20:28:29
@MC_xjhjdA az,我很好奇你只会Py3为甚么会来luogu(