啊!救救我吧!20分!
查看原帖
啊!救救我吧!20分!
1539028
dingjingxuan1234楼主2024/10/25 21:38
#include <bits/stdc++.h>
using namespace std;
bool zhishu(int zs){
	for(int j=2;j<=sqrt(zs);j++){
		if(zs%j==0){
			return 0;
		}
	}
	return 1;
}
int main(){
	long long n,h=0,c=0;
	cin>>n;
	for(int i=2;h<=n;i++){
		if(zhishu(i)){
			c++;
			h=h+i;
			cout<<i<<"\n";
			if(h>=n){
				cout<<c;
				return 0;
			}
		}
	}
}
2024/10/25 21:38
加载中...