zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    龟兔赛跑(动态规划)
    Dividing (多重背包 搜索)
    第k大值01背包问题
    FATE(完全背包)
    01背包 和 完全背包 详解
    放苹果(动态规划)
    max Sum(简单动态规划)
    连连看 优先对列 应用2
    尺取法
    Square(强大的剪枝)
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/7220150.html
Copyright © 2011-2022 走看看