time limit per test1 second

memory limit per test256 megabytes

inputstandard input

outputstandard 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

2

2 3

input

6

output

3

2 2 2

【题目链接】:http://codeforces.com/contest/749/problem/A

【题解】



显然奇数的话就先减个3,然后就是偶数了,一直减2就好;

偶数的话就全都是2。

我写了个枚举。

不知道自己怎么想的。



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; //const int MAXN = x;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0); int n;
vector <int> a,ans; bool is(int x)
{
int len = sqrt(x);
rep1(i,2,len)
if ((x%i)==0)
return false;
return true;
} int main()
{
//freopen("F:\\rush.txt","r",stdin);
rei(n);
rep1(i,2,n)
if (is(i))
a.pb(i);
int now = 0;
while (n)
{
if (n-a[now]>1 || n-a[now]==0)
{
n-=a[now];
ans.pb(a[now]);
}
else
{
now++;
ans.pb(a[now]);
n-=a[now];
}
}
int len = ans.size();
printf("%d\n",len);
rep1(i,0,len-1)
{
printf("%d",ans[i]);
if (i==len-1)
puts("");
else
putchar(' ');
}
return 0;
}

最新文章

  1. zk 起别名时候碰到的问题
  2. 此地址使用了一个通常用于网络浏览以外的端口。出于安全原因,Firefox 取消了该请求
  3. IOS Socket 05-XMPP开始&amp;安装服务器openfire&amp;安装配置客户端
  4. 你真的了解UIEvent、UITouch吗?
  5. MySQL 约束的讲解
  6. JS初学之-效果没出来怎么办?-alert函数测试
  7. PHP中使用CURL实现get和post请求(总结)
  8. Codeforces Gym 100418K Cards 暴力打表
  9. thinkphp 独立分组配置
  10. php url字符转义操作
  11. Smallest Rectangle Enclosing Black Pixels 解答
  12. Unity 之 AfterFixedUpdate,在所有 GameObject FixedUpdate 后执行
  13. javascript 中的闭包
  14. 负载均衡之基于L7负载
  15. JS正则表达式的基础用法
  16. 深入解析 SQL Server 高可用镜像实现原理
  17. Lintcode389 Valid Sudoku solution 题解
  18. django中引入bootstrap4.3
  19. [转帖] CA如何保护自己的私钥
  20. 团队Alpha博客链接目录

热门文章

  1. 【软件安装】我喜欢的notepad插件
  2. Spring+Stomp+ActiveMq实现websocket长连接
  3. Git同步Python代码
  4. iOS开发周报-- 第一期
  5. thinkphp5.0中英文切换
  6. oracle连接命令
  7. TIJ——Chapter Three:Operators
  8. COGS-2638 区间与,异或,询问max
  9. idea 使用优化
  10. header发送Cookie