Codeforces Round #388 (Div. 2) - A
题目链接:http://codeforces.com/contest/749/problem/A
题意:给定一个数n,求把n分解成尽量多的素数相加。输入素数个数和具体方案。
思路:因为要尽量多的素数,所以当n为奇数时用(n/2)-1个素数2还有一个素数3. 当n为偶数时用(n/2)个素数2
#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<time.h>
#include<cmath>
using namespace std;
typedef long long int LL;
int main(){
//#ifdef kirito
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
//#endif
// int start = clock();
int n;
while (scanf("%d", &n) != EOF){
int cnt = ;
if (n % == ){
printf("%d\n", n / );
for (int i = ; i < n / ; i++){
printf("");
printf(i == (n / ) - ? "\n" : " ");
}
}
else{
printf("%d\n", n / );
for (int i = ; i < n / ; i++){
printf(i == (n / ) - ? "" : "");
printf(i == (n / ) - ? "\n" : " ");
}
}
}
//#ifdef LOCAL_TIME
// cout << "[Finished in " << clock() - start << " ms]" << endl;
//#endif
return ;
}
Codeforces Round #388 (Div. 2) - A的更多相关文章
- Codeforces Round #388 (Div. 2)
# Name A Bachgold Problem standard input/output 1 s, 256 MB x6036 B Parallelogram is Back s ...
- Codeforces Round #388 (Div. 2) - C
题目链接:http://codeforces.com/contest/749/problem/C 题意:给定一个长度为n的D/R序列,代表每个人的派别,然后进行发表意见,顺序是从1到n.每个人到他的回 ...
- Codeforces Round #388 (Div. 2) - B
题目链接:http://codeforces.com/contest/749/problem/B 题意:给定平行四边形的3个点,输出所有可能的第四个点. 思路:枚举任意两个点形成的直线,然后利用这两个 ...
- Codeforces Round #388 (Div. 2) A,B,C,D
A. Bachgold Problem time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #388 (Div. 2) 749E(巧妙的概率dp思想)
题目大意 给定一个1到n的排列,然后随机选取一个区间,让这个区间内的数随机改变顺序,问这样的一次操作后,该排列的逆序数的期望是多少 首先,一个随机的长度为len的排列的逆序数是(len)*(len-1 ...
- Codeforces Round #388 (Div. 2) D
There are n people taking part in auction today. The rules of auction are classical. There were n bi ...
- Codeforces Round #388 (Div. 2) A+B+C!
A. Bachgold Problem 任何一个数都可以由1和2组成,由于n是大于等于2的,也就是可以由2和3组成.要求最多的素数即素数越小越好,很明显2越多越好,如果n为奇数则再输出一个3即可. i ...
- Codeforces Round #388 (Div. 2) C. Voting
题意:有n个人,每个人要么是属于D派要么就是R派的.从编号1开始按顺序,每个人都有一次机会可以剔除其他任何一个人(被剔除的人就不在序列中也就失去了剔除其他人的机会了):当轮完一遍后就再次从头从仅存的人 ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
随机推荐
- jquery 自定义click事件执行多次
用jquery绑定一个按钮click事件后,第一次点击后一切正常,第二次点击竟然执行两次,以后越来越多, 后来查看文档发现 jquery click 不是替换原有的function 而是接着添加,所以 ...
- 04 MapReduce原理介绍
大数据实战(上) # MapReduce原理介绍 大纲: * Mapreduce介绍 * MapReduce2运行原理 * shuffle及排序 定义 * Mapreduce 最早是由googl ...
- Timequest静态时序分析(STA)基础
Setup Slack Hold Slack Recovery&Removal Recovery: The minimum time an asynchronous signal must b ...
- 监视 Windows 剪切板
一.先看代码 import win32con,win32gui import win32clipboard as cb class MyWindow(): def __init__(self): #注 ...
- spring 静态注入
1.静态注入 在setter 方法修改为非 static , 然后在上面注入即可 @Component public class WeixinConfig { // token public stat ...
- 使用jstack分析cpu消耗过高的问题
我们使用jdk自带的jstack来分析.当linux出现cpu被java程序消耗过高时,以下过程说不定可以帮上你的忙: 1.top查找出哪个进程消耗的cpu高 21125 co_ad2 18 ...
- tftp服务器简单安装配置
tftp服务器最简单安装配置 1.安装tftp-server sudo apt-get install tftpd-hpa sudo apt-get install tftp-hpa(如果不需要客户端 ...
- Adaboost\GBDT\GBRT\组合算法
Adaboost\GBDT\GBRT\组合算法(龙心尘老师上课笔记) 一.Bagging (并行bootstrap)& Boosting(串行) 随机森林实际上是bagging的思路,而GBD ...
- PHP与MYSQL事务处理
/*MYSQL的事务处理主要有两种方法.1.用begin,rollback,commit来实现begin 开始一个事务rollback 事务回滚commit 事务确认2.直接用set来改变mysql的 ...
- C++中的vector 用法解析
一.概述 vector 是C++标准模板库的部分内容,他是一个多功能的,能够操作多种 数据结构和算法 的模板类和函数库. vector 是一个容器,它能够存放各种类型的对象, ...