help QWQ
查看原帖
help QWQ
1332088
huanzhenyang0420楼主2024/8/17 11:09
#include<bits/stdc++.h>
#include<math.h>
#include<cmath>
using namespace std;
int main() {
	int n,s=0,x=2;
	cin>>n;
	while(s<=n){
		int f=0;
		for(int i=2;i<x;i++)
			if(x%i==0){
				f=1;
				break;
			}
		if(s+x<=n&&f==0){
			s+=x;
			cout<<x<<endl;
		}else if(s+x>n){
			return 0;
		}
		x++;
	}
	return 0;
}


2024/8/17 11:09
加载中...