|
|
back to boardWrong Answer on Test Case 2, Help me out #include<bits/stdc++.h> using namespace std; int arr[15000],newarr[15000]; void sieve() { arr[0]=1; arr[1]=1; newarr[1]=2; for(int i=4; i<15000; i+=2) arr[i]=1; for(int i=3; i<15000; i+=2){ if(arr[i]!=1){ for(int j=i*2; j<15000; j+=i){ arr[j]=1; } } } } int main() { int n, t, k=1; sieve(); //cin>>n; for(int i=1; i<15000; i++){ if(arr[i]!=1){ newarr[k]=i; k++; } } cin>>t; while(t--){ cin>>n; cout<<newarr[n]<<endl; } return 0; } |
|
|