Retoayd @ 2023-09-29 11:31:45
#include <bits/stdc++.h>
using namespace std;
long long n;
bool ccc(int x)
{
if(x==1)
{
return 0;
}
for(int i=2; i*i<=x; i++)
{
if(x%i==0)
{
return 0;
}
}
return 1;
}
int main()
{
cin>>n;
for(int i=1; i<=n; i++)
{
for(int j=1; j<=n-i; j++)
{
int k=n-i-j;
if(i+j+k==n&&ccc(i)&&ccc(j)&&ccc(k))
{
cout<<i<<" "<<j<<" "<<k;
return 0;
}
}
}
}
by SZW_LXZ @ 2024-04-20 10:46:27
输入999
输出2 997 0
显然,你要判断i!=0&&j!=0&&k!=0
by SZW_LXZ @ 2024-04-20 10:46:54
@lycccccc