萌新求助
查看原帖
萌新求助
380333
wbr007楼主2022/2/24 20:26
#include<bits/stdc++.h>
using namespace std;
bool check(int x)
{
	if(x==2) return 1;
	for(int i=2;i<=sqrt(x);i++)
		if(x%i==0) return 0;
	return 1;
}
int main(){
	int l,sum=0,c=0,y=2;
	cin>>l;
    while(sum+y<l){
    	if(check(y)==0){
    		cout<<y<<endl;
    		c++;
    		sum+=y;
    		y++;
		}
	}
	cout<<c<<endl;
	return 0;
}
2022/2/24 20:26
加载中...