题目描述
Output the k-th prime number.
输入
k≤10000
输出
The k-th prime number.
样例输入
10
50
样例输出
29
229
#include <iostream>
//用素数筛法
using namespace std;
const int maxn = 100001;
int prime[maxn], pNum = 0;
bool p[maxn] = { 0 };
void Find_Prime() {
for (int i = 2;i < maxn;i++) {
if (p[i] == false) {
prime[pNum++] = i;
for (int j = i + i;j < maxn;j += i) {
p[j] = true;
}
}
}
}
int main() {
int n;
while (cin >> n) {
Find_Prime();
cout << prime[n-1] << endl;
}
}