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. model类的构造部分属性的对象 产生的json

    在 action方法里, 产生一个对象,可能会是默认的全属性对象,那么在输出的 json就又所有 都出现了. 只是其他的属性全部是 null 那么 在 json里面配上 <!-- json 不产 ...

  2. 实验二 四则运算 完成版 ver.1

    package size; import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JMenuBar; im ...

  3. 对WEB url 发送POST请求

    package com.excellence.spark; import java.util.List; import com.excellence.spark.test.test; import c ...

  4. 字符串经过base64编码后的长度与原字符串的长度是什么关系呀?

    beforeEncode为Encode之前的字符串 那么Encode后的字符串长度为: 1.如果beforeEncode.length()是3的整数倍,那么长度为  (beforeEncode.len ...

  5. 关于JEE web项目 Servlet中 “/” 的解释 ;

    1.关于"/" 可以代表web应用的根目录,也可以代表站点的根目录: 1>如果交给浏览器解析,则代表web站点的根目录,如果交给web服务器解析则代表项目的根目录: 2> ...

  6. 关于request对象的parameter和attribute

    request对象的parameter相关method用于浏览器和服务之间传递数据,且是单向的,只能由浏览器写数据,request读数据,所以只有 String getParameter(String ...

  7. VLD 无法打印堆栈调用情况

    调试时遇到了一个比较郁闷的问题:同样一个MFC工程,复制之后无任何附加操作,VLD便无法正常打印内存泄漏处的堆栈调用了 百度了一下,重要找到了答案:“VLD不支持中文” 复制工程时windows自动在 ...

  8. BZOJ2339 HNOI2011卡农(动态规划+组合数学)

    考虑有序选择各子集,最后除以m!即可.设f[i]为选i个子集的合法方案数. 对f[i]考虑容斥,先只满足所有元素出现次数为偶数.确定前i-1个子集后第i个子集是确定的,那么方案数为A(2n-1,i-1 ...

  9. P2151 [SDOI2009]HH去散步

    题目描述 HH有个一成不变的习惯,喜欢饭后百步走.所谓百步走,就是散步,就是在一定的时间 内,走过一定的距离. 但是同时HH又是个喜欢变化的人,所以他不会立刻沿着刚刚走来的路走回. 又因为HH是个喜欢 ...

  10. Bank Robbery LightOJ - 1163(推方程 注意计算机的计算方式)

    题意:一个数A,如果A去掉它的最后一位就变成了B,即B=A/10,给A - B,求A #include <iostream> #include <cstdio> #includ ...