P3383 0分TLE
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e8+10;
ll n,q,a[N],x=1,k;
bool isPrime(int n)
{
if(n<=1)
{
return false;
}
for(int i=2;i*i<=n;i++)
{
if(n%i==0)
{
return false;
}
}
return true;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>q;
for(int i=2;i<=n;i++)
{
if(isPrime(i))
{
a[x]=i;
x++;
}
}
while(q--)
{
cin>>k;
cout<<a[k]<<endl;
}
return 0;
}