题解 | #Prime Number#
Prime Number
https://www.nowcoder.com/practice/c5f8688cea8a4a9a88edbd67d1358415
#include<bits/stdc++.h> using namespace std; vector<int> dp(110000,1); void zhi(){ for(int i=2;i<110000;i++){ if(dp[i]==1) { for(int j=2;j<110000/i;j++){ dp[j*i]=0; } } } } int main(){ int x; while(cin>>x){ zhi();int i=2; while(x>0){ if(dp[i]==1){ x--; } i++; }i=i-1; cout<<i<<endl; } }