卡在80分,求助!
查看原帖
卡在80分,求助!
1036284
LYL__1107楼主2024/3/17 17:00
#include<bits/stdc++.h>
using namespace std;
bool zs(int a){
	int u=0;
	for(int i=2;i<a;i++){
		if(a%i==0) u++;
	}
	if(u>0) return 0;
	else return 1;
}
int k(int s){
	while(1){
		s++;
		if(zs(s)){
			return s;	
		}
	}
}
int main(){
	int n;
	cin>>n;
	if(n==1){
		cout<<"0";
		return 0;
	} 
	int s=2,x=0,c=0;
	while(1){
		
		if(zs(s)){
			cout<<s<<endl;
			x+=s;
			c++;
		}
		if(x+k(s)>=n) break;
		s++;
	}
	cout<<c;
	return 0;
}
2024/3/17 17:00
加载中...