P1579 哥德巴赫猜想(升级版)
#include <iostream>
#include <cmath>
using namespace std;
int a;
int is_zhishu(int x)
{
if (x==1||x==0)
{
return 0;
}
for (int i=2;i<=sqrt(x);i++)
{
if (x%i==0)
{
return 0;
}
}
return 1;
}
int main()
{
cin>>a;
for (int i=2;i<=a-4;i++)
{
for (int j=i;j<=a-4;j++)
{
int k=a-i-j;
if(k < 2) continue;
if (is_zhishu(i)&&is_zhishu(j)&&is_zhishu(k))
{
cout <<i<<" "<<j<<" "<<k;
return 0;
}
}
}
return 0;
}