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
  • 相关阅读:
    rc-local.service服务启动失败,导致rc.local中的开机启动服务不能启动
    bacula快速部署
    配置github SSH公钥登录
    快速安装zabbix
    编译安装git
    linux系统日志中出现大量systemd Starting Session ### of user root 解决
    根据屏幕高度自适应元素高度
    git+github上传与管理
    ajax简单应用
    自己常用的webstrom快捷键
  • 原文地址:https://www.cnblogs.com/superxuezhazha/p/5677242.html
Copyright © 2011-2022 走看看