1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| #include<bits/stdc++.h> using namespace std;
bool isprime(int x){ if(x==1) return false; else if(x == 2) return true; else { for(int i=2;i<=sqrt(x);i++){ if(x%i==0) return false; } return true; } } int main(){ int n; int s = 0; cin>>n; for(int i=1;i<=1000000;i++){ if(isprime(i)) ++s; if(s == n){ cout<<i<<endl; return 0; } } return 0; }
|