Wyl20110306 @ 2024-07-18 20:03:01
#include<bits/stdc++.h>
using namespace std;
const int N=100000001;
int n;
bool flag[N];
int pri[N],pn;
int main(){
cin>>n;
for(int i=2;i<=n;i++){
if(flag[i]==0) pri[++pn]=i;
for(int j=1;j<=pn&&j*pri[i]<=n;j++){
flag[i*pri[j]]=1;
if(i%pri[j]==0) break;
}
}
for(int i=1;i<=pn;i++) cout<<pri[i]<<endl;
return 0;
}
by Wyl20110306 @ 2024-07-18 20:19:25
@xuhaotian 谢谢,没看题,下次不会了
by hcodm @ 2024-07-19 09:43:09
@Wyl20110306 嘻嘻,撞到你了
by Wyl20110306 @ 2024-07-19 09:47:36
@hcodm 太巧了,有缘