求大佬们看看还有一个wa了
查看原帖
求大佬们看看还有一个wa了
1068299
ice_moon_soul楼主2023/10/7 19:50
#include <iostream>
#include <algorithm>

using namespace std;

bool ispimer(int j)
{
	for (int i = 2; i * i <= j; i++)
	{
		if (j % i == 0) return false;
	}
	return true;
}

int main()
{
	long long sum = 0, rec=0;
	long long n = 0, m = 0;
	cin >> n;
	if (n < 2) cout << "0" << endl;
	else 
	{
		for (int j = 2; j <= 10000000000; j++)
		{
			if (ispimer(j))
			{
				sum += j;
				if (sum >= n) break;
				cout << j << endl;
				rec++;
			}
		}
		cout << rec << endl;
		//cout << sum;
	}
	return 0;
}
2023/10/7 19:50
加载中...