描述
Output the k-th prime number.
输入描述:
k≤10000
输出描述:
The k-th prime number.
示例1
输入:
3
7
输出:
5
17
#define _CRT_SECURE_NO_WARNINGS 1
#include <bits/stdc++.h>
using namespace std;
const int N = sqrt(1e5) + 1;
vector<int> prime; //保存质数
vector<bool> isPrime(N, true);
void Initial() {
isPrime[0] = isPrime[1] = false;
for (int i = 2; i < N; ++i) {
if (!isPrime[i])
continue;
prime.push_back(i);
/* if (i > N / i)
continue; */
for (int j = i * i; j < N; j += i)
isPrime[j] = false;
}
return;
}
int main() {
Initial();
int k;
while (cin >> k)
{
printf("%d\n", prime[k - 1]);
}
return 0;
}