码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces Round #388 (Div. 2) A

时间:2017-07-22 09:57:44      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:include   maximum   first   with   spec   type   unsigned   return   sample   

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

标签:include   maximum   first   with   spec   type   unsigned   return   sample   

原文地址:http://www.cnblogs.com/yinghualuowu/p/7220150.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!