全是TLE!!!还有一个WA!!!
查看原帖
全是TLE!!!还有一个WA!!!
1292414
LeonTexius楼主2024/9/24 18:41
#include<bits/stdc++.h>
using namespace std;
int n;
int check(int a)
{
	int nums = 0;
	for(int i = 1;i <= a;i++)
	{
		if(a % i == 0)
		{
			nums++;
		}
	}
	if(nums == 2)
	{
		return 1;
		
	}
	return 0;
	
}
int main()
{
	cin >> n;
	if(n % 2 == 0)
	{
		cout << 2 << " ";
		n -= 2;
		for(int i = 3;i <= n / 2;i++)
		{
			if(check(i) == 1 && check(n - i) == 1)
			{
				cout << i << " " << n - i;
				break;
			}
		}
	}
	else
	{
		for(int i = 1;i <= n / 3 + 1;i++)
		{
			for(int j = 1;j <= n / 3 + 1;j++)
			{
				if(check(i) == 1 && check(j) == 1 && check(n - i - j) == 1)
				{
					cout << i << " " << j << " " << n - i - j;
					break;
				}
			}
		}
	}
	return 0;
	
}
2024/9/24 18:41
加载中...