Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define max 90000000
- #define maxN 1000000
- #define mod 10000000 + 5
- #define pb push_back
- #define pairs pair<int, int>
- #define vi vector<int>
- #define vb vector<bool>
- #define vii vector<pairs>
- #define lb lower_bound
- #define ub upper_bound
- #define lli long long int
- #define endl '\n'
- using namespace std;
- bool isPrime[max];
- int Prime[maxN];
- void sieve() {
- for (int i = 1; i <= max; i++) {
- isPrime[i] = 1;
- }
- isPrime[0] = 0;
- for (int i = 2; i * i <= max; i++) {
- if(isPrime[i]) {
- for (int j = i * i; j <= max; j += i) {
- isPrime[j] = 0;
- }
- }
- }
- }
- int main() {
- #ifdef Niloy
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- sieve();
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- for (int i = 1, j = 0; i <= max; i++) {
- if(isPrime[i]) {
- Prime[j] = i;
- j++;
- }
- }
- int t, n;
- cin >> t;
- while(t--) {
- cin >> n;
- cout << Prime[n] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement