Codeforces Round #388 (Div. 2) 749A Bachgold Problem
来源:互联网 发布:mac expect ssh 编辑:程序博客网 时间:2024/06/15 13:44
题目传送门:点击打开链接
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 than1.
Recall that integer k is called prime if it is greater than 1 and has exactly two positive integer divisors —1 andk.
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 ton. You can print them in any order. If there are several optimal solution, print any of them.
5
22 3
6
32 2 2
思路:给你一个数n,问你最多能把n分成几个素数的和?输出素数的数量和这些素数。
思路:如果n是偶数的话。那就可以分成n/2个2
如果n是奇数的话。那就可以分成((n-1)/2 -1)个2和一个3
#include<bits/stdc++.h>using namespace std;#define LL long long#define M(a) memset(a,0,sizeof(a))int main(){ int n; while(~scanf("%d",&n)) { if(n==2) { printf("1\n"); printf("2\n"); continue; } if(n%2==0) { printf("%d\n",n/2); for(int i=0;i<n/2;i++) { if(i==0) { printf("2"); } else { printf(" 2"); } } printf("\n"); } else { printf("%d\n",n/2); for(int i=0;i<n/2-1;i++) { printf("2 "); } printf("3\n"); } } return 0;}
- Codeforces Round #388 (Div. 2) 749A Bachgold Problem
- Codeforces Round #388(Div. 2)A. Bachgold Problem【水题】
- Codeforces Round #388 (Div. 2)A Bachgold Problem
- 【codeforces 749A】Bachgold Problem
- Codeforces 749A-Bachgold Problem
- 【codeforces 749A】Bachgold Problem
- codeforces 749A Bachgold Problem
- 749 A. Bachgold Problem
- Codeforces Round #174 (Div. 2) Problem A
- Codeforces Round #324 (Div. 2) PROBLEM A
- Codeforces Round #363 (Div. 2), problem: (A)
- Codeforces Round #401 (Div. 2), problem: (A)
- cf 749 A. Bachgold Problem
- Bachgold Problem CodeForces
- Codeforces Round #221 (Div. 2) (Problem 376A~C)
- Codeforces Round #230 (Div. 2) problem A(小算数)
- Codeforces Round #FF (Div. 2) Problem A DZY Loves Hash
- Codeforces Round #FF (Div. 2):Problem A - DZY Loves Hash
- POJ3109-Inner Vertices
- poj 2398 Toy Storage 【二分】
- 关于sqoop的一些命令
- 使用watch监听input值
- linux 命令终端提示符显示-bash-4.1#解决方法
- Codeforces Round #388 (Div. 2) 749A Bachgold Problem
- GIT常用命令
- ubuntu添加开机自启动脚本
- 低功耗蓝牙cc2541学习笔记之LED-1
- emacs company自动补全的候选来源
- 代码:java日期转换 01-Jul-2017 到20170701
- 萌新的linux之旅3
- uva 11795 Mega Man‘s Missions’ 状态压缩DP
- Django1.11 用户注册登录(1)