C. Slava and tanks
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Slava plays his favorite game "Peace Lightning". Now he is flying a bomber on a very specific map.

Formally, map is a checkered field of size 1 × n, the cells of which are numbered from 1 to n, in each cell there can be one or several tanks. Slava doesn't know the number of tanks and their positions, because he flies very high, but he can drop a bomb in any cell. All tanks in this cell will be damaged.

If a tank takes damage for the first time, it instantly moves to one of the neighboring cells (a tank in the cell n can only move to the cell n - 1, a tank in the cell 1 can only move to the cell 2). If a tank takes damage for the second time, it's counted as destroyed and never moves again. The tanks move only when they are damaged for the first time, they do not move by themselves.

Help Slava to destroy all tanks using as few bombs as possible.

Input

The first line contains a single integer n (2 ≤ n ≤ 100 000) — the size of the map.

Output

In the first line print m — the minimum number of bombs Slava needs to destroy all tanks.

In the second line print m integers k1, k2, ..., km. The number ki means that the i-th bomb should be dropped at the cell ki.

If there are multiple answers, you can print any of them.

Examples
input
2
output
3
2 1 2
input
3
output
4
2 1 3 2 翻译就算了吧 谷歌比我翻译的好不少
抽象一下:每个tank两滴血,tank排列在1*n的网格中,每个网格中有多个tank,你可以在空中进行轰炸,每个tank被炸到后,都会往左右两个方向挑一个移动,炸两次就死了,求用多少炸弹能炸死所有的tank 这个题我没想出来,还是看的别人的题解,但是好多题解都没有证明为什么这么炸这是最佳结论,包括官方题解都说it's easy to prove the strategy is optimal 可能这就是差距吧,我想了好长时间都
想不明白
当然现在也想不明白,之后看能不能在补上吧 先输出偶数位,在输出奇数位,再输出偶数位

丑陋的代码:

#include <iostream>

#include <cstdio>

using namespace std;

int main()

{

int i,j,n;

scanf("%d",&n);

printf("%d\n",n+n/2);

for(i = 2; i <= n; i += 2)

printf("%d ",i);

for(i = 1; i <= n; i += 2)

printf("%d ",i);

for(i = 2; i <= n - 2; i += 2)

printf("%d ",i);

printf("%d\n",i);

}

codeforces877c的更多相关文章

随机推荐

  1. hdu 1686 & poj 2406 & poj 2752 (KMP入门三弹连发)

    首先第一题 戳我穿越;http://acm.hdu.edu.cn/showproblem.php?pid=1686 题目大意好理解,每组输入一个子串和一个母串,问在母串中有多少个子串? 文明人不要暴力 ...

  2. 如何使用queue_delayed_work函数

    本文转自如何使用queue_delayed_work函数 1. delayed_workqueue主要用在需要延迟处理任务的驱动中,这些驱动的特性主要是不能使用中断. delayed_workqueu ...

  3. 关于RNA-Seq数据去接头(Adapter)这事需要讲一讲

    关于RNA-Seq数据去接头(Adapter)这事需要讲一讲 RNA-Seq adapter barcode cutadapt 首先来了解一下三个概念: 1.adapter是一段短的序列已知的核酸链, ...

  4. Python之线程与进程

    今天我们来了解一下Python的线程和进程的管理机制 首先,我们要了解下线程跟进程的概念: 线程(Thread)是操作系统能够进行运算调度的最小的单位,是一堆cpu的指令.他被包含在进程中,是进程中的 ...

  5. nginx指令中的优化(配置文件)

    nginx指令中的优化(配置文件)worker_processes 8; nginx进程数,建议按照cpu数目来指定,一般为它的倍数.worker_cpu_affinity 00000001 0000 ...

  6. Hibernate学习笔记:注解@OneToMany和@ManyToOne的单独使用问题 不成对使用

    以某个实际场景为例,现在两张表:用户表User 订单表Order:很显然用户对订单是一对多的关系.二者注解如下 用户表User @Entity @Table(name="users" ...

  7. RSS工具关注期刊,方便快速获取及时大量的文献信息

    第一步: 第二步: 第三步: RSS : 很好的一个东西,到了中国,咋就水土不服了呢...

  8. 2017/2/8 hibernate + oracle 实现id的自增 同时 hibernate项目跑起来 会自己增加字段的原因 oracle触发器的使用

    hibernate + oracle 实现id的自增 1.在oracle中先创建一个序列 : 序列语法 如下 create  sequence   (序列名称)seq_student_id minva ...

  9. django网页图片验证码功能

    在一个正常的登录系统中,验证码是非常重要的,用于识别人机,毕竟我们都知道,这个世界中存在着万恶的爬虫,验证码有很多种方式,有图片的,有邮件的,有短信的,有拼图的,不管什么样的验证码,目的都是验证访问用 ...

  10. 【转】Centos yum 换源

    [1] 首先备份/etc/yum.repos.d/CentOS-Base.repo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/Cent ...