//土尔逊Torson 编写于2023/05/09 #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cstdio> #include <vector> using namespace std; const int MAXN = 100001; vector<int>prime07101; //保存质数 bool isPrime07101[MAXN]; //标记数组 void Initial07101() { for (int i = 0; i < MAXN; ++i) { //初始化 isPrime07101[i] = true; } isPrime07101[0] = false; isPrime07101[1] = false; for (int i = 2; i < MAXN; ++i) { if (!isPrime07101[i]) { //非质数则跳过 continue; } prime07101.push_back(i); for (int j = i*i; j < MAXN; j += i) { isPrime07101[j] = false; //质数的倍数为非质数 } } return; } int main() { Initial07101(); int n; while (scanf("%d", &n) != EOF) { int count = 0; int pos = 0; for (int i = 0; i < prime07101.size() && count < n; ++i) { if (prime07101[i]) { //记录第 N 个 Prime count++; pos = i; } } printf("%d\n", prime07101[pos]); //输出第 N 个 Prime } system("pause"); return EXIT_SUCCESS; } // 64 位输出请用 printf("%lld")