• Codeforces Round #388 (Div. 2) A


    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
    题意:将数字分解成素数之和形式,要求素数个数尽量多
    解法:作死的填2和3就成
     1 #include<bits/stdc++.h>
     2 typedef long long LL;
     3 typedef unsigned long long ULL;
     4 typedef long double LD;
     5 using namespace std;
     6 #define debug(x) cout << #x" = " << x<<endl;
     7 int main(){
     8     int n;
     9     cin>>n;
    10     cout<<n/2<<endl;
    11     if(n%2){
    12         for(int i=1;i<n/2;i++){
    13             cout<<"2 ";
    14         }
    15         cout<<"3"<<endl;
    16     }else{
    17         for(int i=1;i<=n/2;i++){
    18             cout<<"2 ";
    19         }
    20     }
    21     return 0;
    22 }
  • 相关阅读:
    Swift -- 8.3 多态
    Swift -- 8.2 类的构造与析构
    Swift -- 8.1 继承
    Swift -- 7.6 构造器
    Swift -- 7.5 类型属性,方法
    Swift -- 7.4 方法,下标,可选链
    Swift -- 7.3 类和结构体
    Swift -- 7.2 枚举
    Swift -- 7.1 面向对象简介
    4-5轮选区的不透明度1.7
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/7220150.html
Copyright © 2020-2023  润新知