题解 | #Prime Number#
Prime Number
https://www.nowcoder.com/practice/c5f8688cea8a4a9a88edbd67d1358415
#include<cstdio> #include<vector> #include<cmath> using namespace std; int main(){ int n; vector<int>vec; for (int i = 2; vec.size() < 10000; i++){ int m = sqrt(i); int j = 2; for (; j <= m; j++){ if (i%j == 0){ break; } } if (j>m){ vec.push_back(i); } } while (scanf("%d", &n) != EOF){ printf("%d\n", vec[n - 1]); } }