蒟蒻求助 80分卡住惹QAQ
查看原帖
蒟蒻求助 80分卡住惹QAQ
906264
asdfg11楼主2023/4/15 09:50
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

const int N = 1e6 + 10;

int n, s;
int x;

bool get(int n)
{
	if(n < 2) return false;
	for(int i = 2; i <= n / i; i ++)
	if(n % i == 0) return false;
}

int main()
{
	cin >> n;
	for(int i = i; i <= n; i ++)
	{

		if(s + i > n) 
		{
			cout << x;
			return 0;
		}
 	
	if(get(i))
	{
		s += i;
		cout << i << endl;
		x ++;
	}
	}
	return 0;
}
2023/4/15 09:50
加载中...