༺ཌༀཉི哦啦筛80pts(#2WA)求条༃ༀད༻
查看原帖
༺ཌༀཉི哦啦筛80pts(#2WA)求条༃ༀད༻
681558
Weizhuo_Zhao楼主2024/8/14 16:10
#include<bits/stdc++.h>
using namespace std;
const int MAX_N=100005;
int n,T,l=0,a[MAX_N],x;
bool b[MAX_N];
void ol(){
	for(int i=2;i<=n;i++){
		if(!b[i])
			a[++l]=i;
		for(int j=1;j<=l;j++){
			if(i*a[j]>=MAX_N)
				break;
			b[i*a[j]]=true;
			if(i%a[j]==0)
				break;
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	ol();
	int t=0;
	long long sum=0;
	for(int i=1;i<=l;i++){
		sum+=a[i];
		t++;
		if(sum>n)
			break;
		cout<<a[i]<<'\n';
	}
	cout<<t-1;
	return 0;
	
}
2024/8/14 16:10
加载中...