标签:
#include <iostream>
#include <cmath>
const int N=500000;//数组大小
using namespace std;
int main(){
int n,c,a[N]={0};
cin >> n;
for (int i=1;i<=n;i++){
for (int j=0;j<=c;j++){
if (i==1)
break;
if (i==2){
c=0;
a[c]=i;
//1 cout<<i<<"__";
break;
}
if (i%a[j]==0)
break;
else if (j>=sqrt(c)){//满足条件时,i是素数
c++;
a[c] =i;
// cout<<i<<"__";
break;
}
}
}
/*
for (int i=0; i<=c;++i){
cout <<a[i]<<" ";
}
*/
int b;
cin>>b;
if(b>0)
cout <<"The"<<b<<"th is:"<<a[b-1] <<endl;
cout<<"Total:"<<c+1<<endl;
return 0;
}
标签:
原文地址:http://www.cnblogs.com/jiafeimao444/p/5164202.html