lxznice @ 2024-12-19 20:45:36
#include<bits/stdc++.h>
using namespace std;
bool pd(int n)
{
for(int i=2;i<n;i++)
{
if(n%i==0)return 0;
}
return 1;
}
int main()
{
int n;
cin>>n;
for(int i1=3;i1<=n-6;i1+=2)
{
for(int i2=3;i2<=n-i1-3;i2+=2)
{
int i3=n-i1-i2;
if(pd(i1)&&pd(i2)&&pd(i3))
{
cout<<i1<<" "<<i2<<" "<<i3;
return 0;
}
}
}
return 0;
}
by ruo_aqueous @ 2024-12-19 21:08:36
@lxznice
#include<bits/stdc++.h>
using namespace std;
bool pd(int n)
{
for(int i=2;i<n;i++)
{
if(n%i==0)return 0;
}
return 1;
}
int main()
{
int n;
cin>>n;
for(int i1=2;i1<=n;++i1)
{
for(int i2=i1;i2<=n;++i2)
{
int i3=n-i1-i2;
if(pd(i1)&&pd(i2)&&pd(i3)&&i3>i2)
{
cout<<i1<<" "<<i2<<" "<<i3;
return 0;
}
}
}
return 0;
}