SHARE
TWEET

sieve

a guest Jul 21st, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int mark[15050], prime[15050];
  4. int main(){
  5.     int tc, n, j=1;
  6.     for(int i=2; i*i<=163845; i++){
  7.         for(int j=i+i; j<=163845; j+=i){
  8.             mark[j]=1;
  9.         }
  10.     }
  11.  
  12.     for(int i=2; i<=163845; i++){
  13.         if(mark[i]==0){
  14.             prime[j]=i;
  15.             j++;
  16.         }
  17.     }
  18.     cin >> tc;
  19.     for(int k=1; k<=tc; k++){
  20.         cin >> n;
  21.         cout << prime[n] << endl;
  22.     }
  23.     return 0;
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top