时间限制: 1000 ms 内存限制: 65536 KB
【题目描述】
输入一个正整数n,求第n小的质数。
【输入】
一个不超过10000的正整数n。
【输出】
第n小的质数。
【输入样例】
10
【输出样例】
29
【知识点】
【kk老师的解析】- 高级题库请点击
- 考查学员快速查找质数的方法
- 考查学员嵌套循环的运用
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int n,m,t=0;
cin>>n;
m = n*n;
for(int i=2;i<=m;++i)
{
t = 0;
for(int j=2;j<=sqrt(i);++j)
{
if(i%j==0)t=1;
}
if(t==0)
{
n--;
if(n==0)
{
cout<&l