您的位置:首页 > 其它

(数论)哥德巴赫猜想

2017-08-20 15:53 381 查看
关于偶数的哥德巴赫猜想:任一大于2的偶数都可写成两个素数之和。

关于奇数的哥德巴赫猜想:任一大于7的奇数都可写成三个质数之和的猜想。

【例题1 Dima and Lisa CodeForces - 584D 】

Dima loves representing an odd number as the sum of multiple primes, and Lisa loves it when there are at most three primes. Help them to represent the given number as the sum of at most than three primes.

More formally, you are given an odd numer n. Find a set of numbers pi (1 ≤ i ≤ k), such that

1 ≤ k ≤ 3

pi is a prime

The numbers pi do not necessarily have to be distinct. It is guaranteed that at least one possible solution exists.

Input

The single line contains an odd number n (3 ≤ n < 109).

Output

In the first line print k (1 ≤ k ≤ 3), showing how many numbers are in the representation you found.

In the second line print numbers pi in any order. If there are multiple possible solutions, you can print any of them.

Example

Input

27

Output

3

5 11 11

AC代码:

#include<cstdio>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;

bool isprime(ll n)
{
for(ll i=2;i<=sqrt(n);i++)
if(n%i==0)
return false;
return true;
}

int main()
{
ll n;
scanf("%lld",&n);
if(isprime(n))
{
printf("1\n");
printf("%lld\n",n);
}
else if(n%2==0)
{
for(ll i=n-1;i>=2;i-=2)
{
if(isprime(n-i) && isprime(i))
{
printf("2\n");
printf("%lld %lld\n",i,n-i);
break;
}
}
}
else
{
bool flag=0;
for(ll i=n;i>=2;i-=2)
{
if(!isprime(i))continue;
ll p=n-i;
for(ll j=2;j<p;j++)
{
if(isprime(j) && isprime(p-j))
{
printf("3\n");
printf("%lld %lld %lld\n",i,j,n-i-j);
flag=1;
break;
}
}
if(flag)break;
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: