liyifanglan @ 2024-10-20 22:13:49
#include<bits/stdc++.h>
using namespace std;
int n, m = 1;
bool shu[100000010];
int prime[100000000];
void pdprime(){
for (int i = 2; i <= n; i++){
if (shu[i] == 0){
for (int j = i; i*j <= n; j++){
shu[i*j] = 1;
}
prime[m] = i;
m++;
}
}
}
int main(){
int q;
scanf("%d%d", &n, &q);
pdprime();
while (q--){
int k;
scanf("%d", &k);
printf("%d\n", prime[k]);
}
return 0;
}
by OldDriverTree @ 2024-10-20 22:15:53
@liyifanglan prime 数组开这么大显然会寄,去掉一个 0 试试(
by liyifanglan @ 2024-10-21 21:34:10
@OldDriverTree 还是不行
by OldDriverTree @ 2024-10-21 21:58:05
@liyifanglan 哦好像不是这个原因/jk,仔细看了一下你代码是 i*j
的时候爆 int 了,改成 1ll*i*j
试试