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

Copy
2
output

Copy
3
2 1 2
input

Copy
3
output

Copy
4
2 1 3 2
题意:炸坦克,如果炸第一个坦克,它只能跑到第二个坦克,如果炸第n个坦克,它只能跑到第n-1个坦克,如果炸中间坦克,它可以跑到它相邻的坦克上
分析:先炸偶数位上的坦克(因为偶数总是比奇数少),然后偶数位上的坦克都跑到奇数位上了,再炸奇数位上的坦克,原来偶数位上的坦克就没了,奇数位上的所有坦克跑到偶数位上去了,然后再炸一次偶数位上的坦克,这下所有的坦克都炸没了
 #include<cstdio>
int main()
{
int n;
while(~scanf("%d",&n))
{
printf("%d\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);
}
printf("\n");
}
return ;
}

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

  1. Codeforces 877 C. Slava and tanks

    http://codeforces.com/problemset/problem/877/C   C. Slava and tanks time limit per test 2 seconds me ...

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

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

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

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

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

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

  5. codeforces877c

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

  6. Codeforces Round #442 (Div. 2)A,B,C,D,E(STL,dp,贪心,bfs,dfs序+线段树)

    A. Alex and broken contest time limit per test 2 seconds memory limit per test 256 megabytes input s ...

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

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

  8. CodeForces - 877C

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

  9. Gym 100646 F Tanks a Lot RMQ

    Problem F: Tanks a Lot Imagine you have a car with a very large gas tank - large enough to hold what ...

随机推荐

  1. 通过atomic_flag简单自旋锁实现简单说明标准库中锁使用的memory_order

    在使用标准库中的加锁机制时,例如我们使用std::mutex,写了如下的代码(下面的代码使用condition_variable可能更合适) std::mutex g_mtx; int g_resNu ...

  2. 简单的单进程FTP服务器的实现

    一.功能说明: 1.本程序基于socket实现客户端与服务器端的单进程交互 2.用到的用户名:whw,密码abc123——服务器端密码的验证利用hashlib模块进行MD5的编码以确保通信安全. 3. ...

  3. Jmeter(三十三)Stepping Thread Group

    碰巧最近在做性能测试,就记一下Jmeter的第三方插件Stepping Thread Group. 具体一些插件信息,可以去:jmeter-plugins.org去进行下载. 该插件目前是已经被弃用的 ...

  4. 使用Redis-Dump 导出、导入redis数据

    一.安装ruby https://www.cnblogs.com/EikiXu/p/9406707.html 二.安装redis-dump工具 yum install ruby rubygems ru ...

  5. arm irq system

    http://blog.csdn.net/m_o_bz/article/details/40574713 http://blog.csdn.net/xiafeng1113/article/detail ...

  6. Linux TCP/IP调优-Linux内核参数注释

    固定文件的内核参数 下列文件所在目录: /proc/sys/net/ipv4/ 名称 默认值 建议值 描述 tcpsyn_retries 5 1 对于一个新建连接,内核要发送多少个SYN连接请求才决定 ...

  7. 更换Git的地址;

    Git地址变了,Android Studio更新和提交代码都用不了了:需要把新的Git地址更换一下: 1.打开git项目的文件夹,进入git操作框: 2. git remote -v 查看现有地址: ...

  8. 解决IIS7下主机名灰色无法修改问题

    打开IIS ,找到网站,右击编辑绑定时: 关于导入iis   .pfx格式的证书后,编辑绑定时,主机名为灰色的问题 解决方法 : (1)打开C:\Windows\system32\inetsrv\co ...

  9. pycharm中快捷键的使用

    转载自:https://blog.csdn.net/fighter_yy/article/details/40860949 Alt+Enter 自动添加包 shift+O 自动建议代码补全 Ctrl+ ...

  10. angularjs的cache

    首先要引入angular-cookies.js插件 angular.module('app').service('cache', ['$cookies', function($cookies){ th ...