1e9 以内的判断一个数是否是素数,可以直接朴素的暴力。
 
这倒题除了考虑1e9以内的素数的判断,还有一个歌德巴赫猜想:任意一个奇数都可一分解为三个素数的和。
第三个结论:素数是密集的,1e9以内,相邻的素数之间的间隔不会大于300,所以直接枚举也不会浪费掉太多的时间。
 
这里还有一点需要注意的是:朴素的判断是否是素数,i<=saqrt(n).今天的天梯赛由于记错了这个条件,导致没有求出素数,一道二十分的题没有做,好伤心。
Dima and Lisa

Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

Dima loves representing an odd number as the sum of multiple primes, and Lisa loves it when there are at most three primes. Help them to represent the given number as the sum of at most than three primes.

More formally, you are given an odd numer n. Find a set of numbers pi (1 ≤ i ≤ k), such that

  1. 1 ≤ k ≤ 3
  2. pi is a prime

The numbers pi do not necessarily have to be distinct. It is guaranteed that at least one possible solution exists.

Input

The single line contains an odd number n (3 ≤ n < 109).

Output

In the first line print k(1 ≤ k ≤ 3), showing how many numbers are in the representation you found.

In the second line print numbers pi in any order. If there are multiple possible solutions, you can print any of them.

Sample Input

Input
27
Output
3
5 11 11

CodeForces 584D Dima and Lisa的更多相关文章

  1. Codeforces Round #324 (Div. 2) D. Dima and Lisa 哥德巴赫猜想

    D. Dima and Lisa Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/probl ...

  2. Codeforces Round #324 (Div. 2)D. Dima and Lisa 数学(素数)

                                                     D. Dima and Lisa Dima loves representing an odd num ...

  3. 【Codeforces 584D】Dima and Lisa

    [链接] 我是链接,点我呀:) [题意] 让你把一个奇数n分成最多个质数的和 [题解] 10的9次方以内,任意两个质数之间的差距最大为300 因此可以这样,我们先从i=n-2开始一直递减直到i变成最大 ...

  4. Codeforces Round #324 (Div. 2) Dima and Lisa 哥德巴赫猜想

    原题链接:http://codeforces.com/contest/584/problem/D 题意: 给你一个奇数,让你寻找三个以内素数,使得和为这个奇数. 题解: 这题嘛...瞎比搞搞就好,首先 ...

  5. Codeforces Little Dima and Equation 数学题解

    B. Little Dima and Equation time limit per test 1 second memory limit per test 256 megabytes input s ...

  6. F - Dima and Lisa(哥德巴赫猜想)

    Problem description Dima loves representing an odd number as the sum of multiple primes, and Lisa lo ...

  7. codeforces B. Dima and Text Messages 解题报告

    题目链接:http://codeforces.com/problemset/problem/358/B 题目意思:给出n个单词(假设为word1,word2.word3...wordn)和一句test ...

  8. codeforces A. Dima and Continuous Line 解题报告

    题目链接:http://codeforces.com/problemset/problem/358/A 题目意思:在横坐标上给出n个不同的点,需要把前一个点跟后一个点(这两个点的顺序是紧挨着的)用一个 ...

  9. codeforces 400D Dima and Bacteria 并查集+floyd

    题目链接:http://codeforces.com/problemset/problem/400/D 题目大意: 给定n个集合,m步操作,k个种类的细菌, 第二行给出k个数表示连续的xi个数属于i集 ...

随机推荐

  1. LaTeX之参考文献的写法

    在编写latex文件时,参考文献是个比较头疼的问题,以前自己写的时候总是用 \begin{thebibliography}\bibitem author,article, year, vol,\end ...

  2. C/C++ 语言中的表达式求值

    在此,首先向裘老师致敬! 裘宗燕:C/C++ 语言中的表达式求值 经常可以在一些讨论组里看到下面的提问:“谁知道下面C语句给n赋什么值?” m = 1; n = m+++m++; 最近有位不相识的朋友 ...

  3. Javascript中的对象(二)

    Javascript是一种基于原型的对象语言,而不是我们比较熟悉的,像C#语言基于类的面向对象的语言.在前一篇文章中,我们已经介绍了Javascript中对象定义的创建.接下来我们来介绍一下Javas ...

  4. [转]ASP.NET Core 1.0: Using Entity Framework Core 1.0 - Transaction

    本文转自:http://blog.csdn.net/alvachien/article/details/51576961 跟Entity Framework之前的版本不同,Class DbContex ...

  5. [转]Loading and Running a Local Package Programmatically

    本文转自:http://msdn.microsoft.com/en-us/library/ms136090.aspx You can run Integration Services packages ...

  6. [转]SQL 2005 开启OpenRowset/OpenDatasource的办法

    本文转自:http://www.cnblogs.com/chenghm2003/archive/2008/09/12/1289793.html 1.开始 —> 所有程序  —> Micro ...

  7. WAF实现扫描器识别

    目前安全测试的软件越来越多,也越来越强大,越来越多的人成为[黑客],今天在网上看到一个文章说拦截wvs的扫描,勾起了我写这篇文章的欲望.   因为公司的三大业务之一就有一个云waf,每天拦截的日志里面 ...

  8. 流畅的python第十七章使用期物处理并发

    从 Python 3.4 起,标准库中有两个名为 Future 的类:concurrent.futures.Future 和asyncio.Future.这两个类的作用相同:两个 Future 类的实 ...

  9. Newtonsoft.Json.4.5.11使用方法总结---反序列化json字符串

    写在开头: 最近项目需求,需要在C#中处理json字符串,毫不犹豫的下载了Newtonsoft.Json 4.5.11(2012.12.17)http://json.codeplex.com/,然后百 ...

  10. UISegmentedControl 修改字体大小 和 颜色

    UISegmentedControl 修改字体大小 和 颜色 大小: UIFont *font = [UIFont boldSystemFontOfSize:14.0f]; NSDictionary ...