#include<bits/stdc++.h>
using namespace std;
int main()
{
int l,time1 = 0,all = 0,number = 2; //time1用来存有几个质数,all用来和l比较大小,number用来从2开始向上枚举所有质数
cin>>l;
while(all<l)
{
int a = 0;
for(int i = 1;i<=number;i++)
{
if(number%i == 0)
{
++a;
}
}
if(a == 2)
{
cout<<number<<endl;
all+=number;
++time1;
}
++number;
}
cout<<time1;
return 0;
}
可过一组样例,请就我的代码来回答,thanks