用户输出
3
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#81721 | #105. zxh的继承顺位 | Accepted | 100 | 1683 ms | 376 K | C++ / 422 B | 木棉之瞳 | 2023-01-10 15:48:29 |
#include <iostream>
#include <math.h>
using namespace std;
bool isPrime(int n) {
if (n == 1)
return false;
if (n == 2)
return true;
for (int i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return true;
}
int main() {
int pos;
int count = 0;
int key = 1;
cin >> pos;
while (count < pos) {
if (isPrime(key) == true)
count++;
key++;
}
cout << key - 1 << endl;
return 0;
}