博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces 877 C. Slava and tanks
阅读量:6000 次
发布时间:2019-06-20

本文共 1839 字,大约阅读时间需要 6 分钟。

 
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 celln - 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 题意: n列格子上有inf辆坦克 每辆坦克两滴血 向第i列扔炸弹,第i列的坦克会移动到i-1和i+1列,减一滴血 问最少扔多少炸弹,炸毁所有坦克 先往偶数格打,所有坦克跑到奇数格 再往奇数格打,所有坦克跑到偶数格 再往偶数格打,所有坦克打死
#include
using namespace std;int n;int main(){ scanf("%d",&n); printf("%d\n",n+n/2); for(int i=2;i<=n;i+=2) printf("%d ",i); for(int i=1;i<=n;i+=2) printf("%d ",i); for(int i=2;i<=n;i+=2) printf("%d ",i);}

 

转载于:https://www.cnblogs.com/TheRoadToTheGold/p/7732368.html

你可能感兴趣的文章
IOS(CGGeometry)几何类方法总结
查看>>
学会放下包袱,热爱单例
查看>>
一个通用并发对象池的实现
查看>>
才知道系列之GroupOn
查看>>
⑲云上场景:超级减肥王,基于OSS的高效存储实践
查看>>
linux kswapd浅析
查看>>
EJB,产品 or 标准?
查看>>
openstack newton 负载均衡Lbaas配置
查看>>
2016年4月7日
查看>>
SpringData+Redis存储
查看>>
C#中用SharpZipLib生成gzip/解压文件
查看>>
JSON Tips
查看>>
Visual Studio 2013 配置OpenGL环境变量
查看>>
iOS开发网络篇之文件下载、大文件下载、断点下载
查看>>
Haproxy安装部署
查看>>
Sublime Text 3 插入日期时间等
查看>>
ios应用程序图标问题
查看>>
mac下安装mysql
查看>>
牛客网《JavaScript》能力评测练习2
查看>>
IOS初级教程2:UITapGestureRecognizer手势识别的简单使用
查看>>