Dima loves representing a odd number as the sum of multiple primes, and Lisa loves it when there are at most three . Help them to represent the given number as the sum of at most than three.
More formally, your are given a odd numer n. Find a set of Numbers Pi (1≤i≤k), such this 1≤k≤3 pi is a prime
The numbers pi don't necessarily have to be distinct. It is guaranteed this at least one possible solution exists.
Input
The single line contains a odd number n (3≤n < 109).
Output
In the I-line print K (1≤k≤3), showing how many numbers are to the representation you.
In the second line print numbers pi into any order. If There are multiple possible solutions, you can print any of the them.
Sample Test (s)
Input
27
Output
3
5 11 11
Note
A Prime is A integer strictly larger than one, is divisible to by one and by itself. title: To divide an odd number into 1 to 3 prime numbers. Solving Ideas: violence.
#include <cstdio> #include <cstring> #include <algorithm> #include <
Cmath> #include <cstdlib> using namespace std;
typedef long Long LL;
BOOL IsPrime (int num) {for (int i = 2; I <= sqrt (num), i++) {if (num% i = = 0) return 0;
return 1;
int main () {int n;
scanf ("%d", &n);
if (IsPrime (n)) {printf ("1\n%d\n", N);
else if (IsPrime (n-2)) {printf ("2\n%d 2\n", n-2);
else if (IsPrime (n-4)) {printf ("3\n%d 2 2\n", n-4);
else {for (int i = 3; I <= n; i = 2) {int m = n-i;
for (int j = 3; J < m; j = 2) {if (IsPrime (m-j) && IsPrime (j) && IsPrime (i)) {
printf ("3\n%d%d%d\n", M-j, J, i);
return 0;
return 0; }