标签:ios bool ++ include ber prime pac 题目 return
Output the k-th prime number.
k≤10000
The k-th prime number.
#include <iostream>
using namespace std;
bool is_primer(int n){
for(int i = 2; i * i <= n; i++){
if(n % i == 0){
return false;
}
}
return true;
}
int main(){
int k;
while(cin >> k){
int count = 0;
for(int i = 2; ; i++){
if(is_primer(i)){
count++;
}
if(count == k){
cout << i << endl;
break;
}
}
}
return 0;
}
标签:ios bool ++ include ber prime pac 题目 return
原文地址:https://www.cnblogs.com/zhuobo/p/10263260.html