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. Delphi控件开发浅入深出(三)

    三.开关控件TlincoSwitch 用过Delphi1(好古老的东东呀!)的人相信都记得这个开关控件 ,不知道当初Borland为什么把这么一个在开发普通应用程序中应用不到的工控控件放到Delphi ...

  2. 常见前端UI框架

    祈澈姑娘 程序员一枚 本文作者祈澈姑娘,转载请声明 前端的技术日渐更新,最近得空,将前端常见的框架总结了一下,在开发的过程之中,有了这些,不断能够提高自己的工作效率,还可以在工作之余了解更多. 1.L ...

  3. Maven仓库设置代理

    线上服务器是没有外网环境的, 添加代理配置如下: <settings>     ...    <proxies>       <proxy>          &l ...

  4. 转:用十条命令在一分钟内检查Linux服务器性能

    转自:http://www.infoq.com/cn/news/2015/12/linux-performance?utm_campaign=rightbar_v2&utm_source=in ...

  5. Jconsole

    Jconsole 1.1 简介以及连接 JConsole是一个基于JMX的GUI工具,用于连接正在运行的JVM,它是Java自带的简单性能监控工具.下面以对tomcat的监控为例,带领大家熟悉Jcon ...

  6. 如何修改JComboBox的宽度

    代码: String[] arr={"http://itts.ihe.ufo.com/rtts/ws.jsp","http://ittsstg.ihe.ufo.com/r ...

  7. .Net Framemwork 之 值类型和引用类型的存储

    C#把数据类型分为两种:值类型 和 引用类型.值类型存储在堆栈中,而引用类型存储在托管堆上. 一.值类型和引用类型变量的存储 首先,变量是存储信息的基本单元,而对于计算机内部来说,变量就相当于一块内存 ...

  8. 4CIF是什么意思

    QCIF:176X144 CIF:352X288 2CIF:704X288 DCIF:584X384 4CIF:704X576 CIF是常用的标准化图像格式(Common Intermediate F ...

  9. python版本管理--pyenv

    python版本环境管理 下载依赖 yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readli ...

  10. web页面查看Tomcat服务器指标

    在进行性能测试时,一般都需要对应用服务器进行监控,监控的指标包括应用服务器的JVM使用状况.可用连接数.队列长度等信息.商业的应用服务器如WebLogic.WebSphere等都提供了Console对 ...