首页 > 代码库 > Codeforces Round #388 (Div. 2) A

Codeforces Round #388 (Div. 2) A

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
2
2 3
input
6
output
3
2 2 2
题意:将数字分解成素数之和形式,要求素数个数尽量多
解法:作死的填2和3就成
 1 #include<bits/stdc++.h>
 2 typedef long long LL;
 3 typedef unsigned long long ULL;
 4 typedef long double LD;
 5 using namespace std;
 6 #define debug(x) cout << #x" = " << x<<endl;
 7 int main(){
 8     int n;
 9     cin>>n;
10     cout<<n/2<<endl;
11     if(n%2){
12         for(int i=1;i<n/2;i++){
13             cout<<"2 ";
14         }
15         cout<<"3"<<endl;
16     }else{
17         for(int i=1;i<=n/2;i++){
18             cout<<"2 ";
19         }
20     }
21     return 0;
22 }

 

Codeforces Round #388 (Div. 2) A