hello @righley
ur code is not completely correct.
a) first of all build sieve upto 10^6 .
b) store all prime numbers upto 10^6 in some array .
c) u need answer t test cases but u r only considering one test case. use loop to read and print t test case.
#include <iostream>
#include <vector>
using namespace std;
#define MAX 10000000
vector<bool>isPrime (MAX,true);
unsigned primearray[5761459];
void gen_primes(){
isPrime[0]=isPrime[1]=false;
for(unsigned i=2;i*i<=MAX;i++){
if(isPrime[i]){
for(unsigned j=i;j*i<=MAX;j++) isPrime[i*j]=false;
}
}
unsigned idx = 1;
primearray[0]=2;
for(int i=3;i<=MAX;i+=2){
if(isPrime[i]){
primearray[idx++]=i;
}
}
}
int main(int argc, char const *argv[])
{
gen_primes();
int t;
cin>>t;
while(t--) {
int n;
cin>>n;
cout<<primearray[n-1]<<endl;
}
return 0;
}
```