#include<iostream>
#include<vector>
using namespace std;
int a[10009]={0};
void prime(){
a[0] = a[1] = 0;
a[2] = 1;
for(int i=3;i<=10009;i+=2){
a[i] = 1;
}
for(int i=3;i<=10009;i+=2){
if(a[i]){
for(int j = i*i; j<=10009; j+=2*i){
a[j] = 0;
}
}
}
return;
}
void check(int n){
// int p[n];
vector<int> v;
for(int i=2;i<=10009;i++){
if(a[i]){
v.push_back(i);
}
}
cout<<v[n-1]<<'\n';
}
int main() {
int test;
prime();
cin>>test;
while(test--){
int n;
cin>>n;
check(n);
}
return 0;
}
Problem:
https://hack.codingblocks.com/contests/c/587/52
facing run time error, code working fine though.
@Khushboo can you look into it?