1 条题解
-
0
思路
枚举候选并试除到平方根;第10000个素数规模可直接计算。按题面规定的输入输出协议处理;数据、边界和算法核验记录保存在本批教师资料。
参考程序(C++11)
#include <bits/stdc++.h> using namespace std; long long gcdll(long long a,long long b){while(b){long long t=a%b;a=b;b=t;}return a;} int main(){ios::sync_with_stdio(false);cin.tie(nullptr);const int p=1099; int n;cin>>n;for(int x=2;;x++){bool ok=true;for(int d=2;d*d<=x;d++)if(x%d==0){ok=false;break;}if(ok&&--n==0){cout<<x;break;}} cout<<"\n";return 0;}
- 1