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<cstdio>

using namespace std;

int n;

int main()
{
scanf("%d",&n);
printf("%d\n",n+n/);
for(int i=;i<=n;i+=) printf("%d ",i);
for(int i=;i<=n;i+=) printf("%d ",i);
for(int i=;i<=n;i+=) printf("%d ",i);
}

Codeforces 877 C. Slava and tanks的更多相关文章

  1. Slava and tanks 877C

    C. Slava and tanks time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  2. codeforces 414D Mashmokh and Water Tanks

    codeforces 414D Mashmokh and Water Tanks 题意 题解 \(a_i\):第 \(i\) 层的结点个数. \(b_i\):第 \(i\) 层初始有水的结点个数. 如 ...

  3. Codeforces 877C Slava and tanks(思维)

    题目链接:http://codeforces.com/problemset 题目大意:有n个格子,某些格子里可能有一个或多个坦克,但不知道具体位置,每个坦克被轰炸一次就会移动到相邻的格子里(第1个格子 ...

  4. 【Codeforces Round #442 (Div. 2) C】Slava and tanks

    [链接] 我是链接,点我呀:) [题意] 有n个位置,每个位置都可能有不定数量的tank; 你每次可以选择一个位置投掷炸弹. 并且,这个位置上的所有tank都会受到你的攻击. 并且失去一点体力. 然后 ...

  5. Codeforces 877 D. Olya and Energy Drinks

    http://codeforces.com/contest/877/problem/D   D. Olya and Energy Drinks time limit per test 2 second ...

  6. codeforces 877 E. Danil and a Part-time Job(线段树(dfs序))

    题目链接:http://codeforces.com/contest/877/problem/E 题解:显然一看就感觉要么树链剖分要么线段树+dfs序,题目要求的操作显然用线段树+dfs序就可以实现. ...

  7. 887C. Slava and tanks#轰炸弹坦克游戏(分析)

    题目出处:http://codeforces.com/problemset/problem/877/C 题目大意:按照游戏规则,求最小炸弹使用次数 #include<iostream> u ...

  8. 【codeforces 175D】 Plane of Tanks: Duel

    http://codeforces.com/problemset/problem/175/D (题目链接) 题意 A,B两人玩坦克大战,坦克有生命值,射击间隔,伤害范围,未命中的概率.问A赢的概率是多 ...

  9. Codeforces Round #442 Div.2 A B C D E

    A. Alex and broken contest 题意 判断一个字符串内出现五个给定的子串多少次. Code #include <bits/stdc++.h> char s[110]; ...

随机推荐

  1. DPDK QoS_meter 源码阅读

    main.c /* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2016 Intel Corporation */ #inclu ...

  2. python learning OOP1.py

    class Student(object): # 构造函数 # 第一个参数永远是 self 表示一个实例本身,但是传参的时候不需要传 # 在Python中,实例的变量名如果以__开头,就变成了一个私有 ...

  3. Mac 下搭建 Apache 服务器

    Apache作为最流行的Web服务器端软件之一,它的优点与地位不言而喻.下面介绍下在Mac下搭建Apache服务器的步骤: (1)“前往” –>”个人” (2)在你的个人目录下新建一个文件夹,改 ...

  4. 使用Ubuntu编译Linux内核

    1.下载内核并解压到 /usr/src 目录下 在终端执行以下命令即可下载 4.16.14版本(目前最新的稳定版)的内核到当前shell打开的目录下 wget https://cdn.kernel.o ...

  5. 微信小程序 功能函数 openid本地和网络请求

    本地-------------------------------------------------------------------------------------------------- ...

  6. js & 快捷键 & vue bind bug

    js & 快捷键 & vue bind bug how to prevent addEventListener bind many times solution dataset &am ...

  7. sqlserver查询数据库中包含某个字段的所有表和所有存储过程

    1.查询包含某字段的所有表 select object_name(id) objName,Name as colName from syscolumns where (name like'%你要查询的 ...

  8. mysql 开发基础系列3

    日期类型 如果要用来表示年月日,通常用DATE 来表示. 如果要用来表示年月日时分秒,通常用DATETIME 表示. 如果只用来表示时分秒,通常用TIME 来表示. TIMESTAMP表示格式 :YY ...

  9. 关于nginx的一点记录

    (1) 安装nginx官网下载:http://nginx.org下载适合Windows的安装包,是一个压缩包,直接解压就可以了. (2) 启动nginx有三种方式启动:a. 双击nginx.exe图标 ...

  10. (待修莫队 没过! 抽空在检查)Dynamic len(set(a[L:R])) UVA - 12345

    #include <iostream> #include <cstdio> #include <sstream> #include <cstring> ...