|
|
back to boardwhy wrong answer?? #include<bits/stdc++.h> using namespace std; int primes[300001],nprime; int mark[1000002]; #define MAX_SIZE 1000005 void sieve(){ int i,j,limit = sqrt(MAX_SIZE*1.0)+2; mark[1]=1; for(i=4;i<=MAX_SIZE;i+=2)mark[i]=1; primes[nprime++]=2; for(i=3;i<=MAX_SIZE;i+=2){ if(!mark[i]){ primes[nprime++]=i; if(i<=limit){ for(j=i*i;j<=MAX_SIZE;j+=i*2){ mark[j]=1; } } } } } int main(){ sieve(); int n; cin>>n; while(n--){ int x; cin>>x; cout<<primes[x-1]<<endl; } } |
|
|