A. Bachgold Problem

来源:互联网 发布:什么是世界货币 知乎 编辑:程序博客网 时间:2024/06/05 19:58

time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Bachgold problem is very easy to formulate. Given a positive integer n represent it as a sum of maximum possible number of prime numbers. One can prove that such representation exists for any integer greater than 1.

Recall that integer k is called prime if it is greater than 1 and has exactly two positive integer divisors — 1 and k.

Input

The only line of the input contains a single integer n (2 ≤ n ≤ 100 000).

Output

The first line of the output contains a single integer k — maximum possible number of primes in representation.

The second line should contain k primes with their sum equal to n. You can print them in any order. If there are several optimal solution, print any of them.

Examples
input
5
output
22 3
input
6
output
32 2 2


解题说明:本题是求出一组和为n的素数,最简单的想法是输出2和3


#include<cstdio>#include <cstring>#include<cmath>#include<iostream>#include<algorithm>#include<vector>#include <map>using namespace std;int main(){    int k,i;    scanf("%d",&k);    printf("%d\n",k/2);    for(i=0;i<k/2-1;i++){printf("%d ",2);}    if(k%2){printf("%d\n",3);}else{printf("%d\n",2);}return 0;}


0 0
原创粉丝点击