Codeforces Round #388 (Div. 2) A
Posted 樱花落舞
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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.
The only line of the input contains a single integer n (2?≤?n?≤?100?000).
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.
5
2
2 3
6
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 }
以上是关于Codeforces Round #388 (Div. 2) A的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #388 (Div. 2) A
Codeforces Round #388 (Div. 2) D
Codeforces Round #388 (Div. 2) C. Voting
Codeforces Round #388 (Div. 2) 749E(巧妙的概率dp思想)