zoukankan      html  css  js  c++  java
  • CodeForces 584D Dima and Lisa

    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
  • 相关阅读:
    python接口测试(二)——配置文件的使用
    python接口测试(一)——http请求及token获取
    jmeter接口测试--响应结果Unicode转码成中文
    jmeter接口测试--获取token
    jmeter接口测试--参数化
    Sysbench安装步骤及详情
    云数据库安装及使用
    npm start 和 npm run start的关系
    使用JS控制伪元素的几种方法
    html5新属性
  • 原文地址:https://www.cnblogs.com/superxuezhazha/p/5677242.html
Copyright © 2011-2022 走看看