LeonTexius @ 2024-09-24 18:41:27
#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;
}
by luoyebushiye @ 2024-09-24 18:57:14
#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;
return 0;
}
}
}
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;
return 0;
}
}
}
}
return 0;
}
@AshtonHuang Ac了
by LeonTexius @ 2024-09-24 19:03:41
@luoyebushiye 拴Q