全部TLE了
查看原帖
全部TLE了
1174639
qyy2014楼主2024/12/28 20:08
#include<bits/stdc++.h>
using namespace std;
bool zs(int n){
	int i;
	bool f = true;
	for(i = 2;i <= sqrt(n);i++){
		if(n % i == 0){
			f = false;
			break;
		}
	}
	if(n <= 1){
		f = false;
	}
	return 0;
}
int main(){
	long long l,i = 1,t = 0,t2 = 0;
	cin>>l;
	while(1){
		if(zs(i) == true){
			if(t+i<=l) cout<<i<<endl,t2++,t+=i;
			else break;
		}
		i++;
	}
	cout<<t2<<endl;
	return 0;
}
2024/12/28 20:08
加载中...