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. Java 反射 不定参数bug

    遇到的第一个关于反射的bug:java.lang.IllegalArgumentException: wrong number of arguments的问题解析如下: 1.错误bug wrong n ...

  2. 汇编语言段和RSEG用法

    RSEG是段选择指令,要想明白它的意思就要了解段的意思.段是程序代码或数据对象的存储单位.程序代码放到代码段,数据对象放到数据段.段分两种,一是绝对段,一是再定位段.绝对段在汇编语言中指定,在用L51 ...

  3. fx投影效果分离

    虽然忙着花花二期三期bug.bug  ing,修改等待中突然看见一张logo.文字下面的阴影图,如下,就满脑子在想阴影到底咋做的.. 七拼八凑的尝试后大体样子是有,终究没有上图那种字体轮廓的阴影... ...

  4. PAT 1024 科学计数法

    https://pintia.cn/problem-sets/994805260223102976/problems/994805297229447168 科学计数法是科学家用来表示很大或很小的数字的 ...

  5. Excel中用REPT函数制作图表

    本文从以下七个方面,阐述在Excel中用REPT函数制作图表: 一. 图形效果展示 二. REPT语法解释 三. REPT制作条形图 四. REPT制作漏斗图 五. REPT制作蝴蝶图 六. REPT ...

  6. 微信 小程序布局 scroll-view

      //滚动触底事件 <scroll-view scroll-y lower-threshold="0" bindscrolltolower="scrollBott ...

  7. eclipse 导入 gradle 项目遇到 UnsupportedConfigurationException 异常

    异常描述: org.eclipse.buildship.core.UnsupportedConfigurationException: Project at 'D:\XXXX_workspace\XX ...

  8. oracle表空间到32G后扩容

    ), ) total_space FROM dba_data_files ORDER BY tablespace_name; /*查看表空间的使用情况*/ select a.a1 表空间名称, tru ...

  9. POJ2699_The Maximum Number of Strong Kings

    这题目,,,真是...诶.坑了好久. 给一个有向图.U->V表示U可以打败V并得一分. 如果一个人的得分最高,或者他打败所有比自己得分高的人,那么此人就是king. 现在给出每个人的得分,求最多 ...

  10. TypeError: to_categorical() got an unexpected keyword argument 'nb_classes'

    在学习莫烦教程中keras教程时,报错:TypeError: to_categorical() got an unexpected keyword argument 'nb_classes',代码如下 ...