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
2
output
3
2 1 2
input
3
output
4
2 1 3 2 翻译就算了吧 谷歌比我翻译的好不少
抽象一下:每个tank两滴血,tank排列在1*n的网格中,每个网格中有多个tank,你可以在空中进行轰炸,每个tank被炸到后,都会往左右两个方向挑一个移动,炸两次就死了,求用多少炸弹能炸死所有的tank 这个题我没想出来,还是看的别人的题解,但是好多题解都没有证明为什么这么炸这是最佳结论,包括官方题解都说it's easy to prove the strategy is optimal 可能这就是差距吧,我想了好长时间都
想不明白
当然现在也想不明白,之后看能不能在补上吧 先输出偶数位,在输出奇数位,再输出偶数位

丑陋的代码:

#include <iostream>

#include <cstdio>

using namespace std;

int main()

{

int i,j,n;

scanf("%d",&n);

printf("%d\n",n+n/2);

for(i = 2; i <= n; i += 2)

printf("%d ",i);

for(i = 1; i <= n; i += 2)

printf("%d ",i);

for(i = 2; i <= n - 2; i += 2)

printf("%d ",i);

printf("%d\n",i);

}

codeforces877c的更多相关文章

随机推荐

  1. MySql5.5 SQL优化 慢查询日志存储

    一.MySql的慢查询日志的开启和存储 1.查看是否把没有使用索引的SQL记录到慢查询日志中,查看 log_queries_not_using_indexes 变量; show VARIABLES L ...

  2. nginx 启动报错 “/var/run/nginx/nginx.pid" failed” 解决方法

    问题: 重启虚拟机后,再次重启nginx会报错: open() "/var/run/nginx/nginx.pid" failed (2: No such file or dire ...

  3. BZOJ3191或洛谷2059 [JLOI2013]卡牌游戏

    BZOJ原题链接 洛谷原题链接 我们可以倒着来\(DP\). 设\(f[i][j]\)表示剩余\(i\)个人,从庄家数起第\(j\)个人的胜率,设当前枚举到第\(k\)张牌,该情况下这一轮淘汰的位置为 ...

  4. Android Text Color设置不当造成信息不显示

    Android Text Color设置不当造成信息不显示 Android 的TextView 可以设置颜色,默认我们可以设置成 #000000 ,但某一次设置成了#00000000 ,就是多了两个0 ...

  5. List<? extends T>和List<? super T>之间有什么区别?

    List<? extends T>表示类型的上界为T,即参数化的类型可能是T也可能是T的子类.<? extends T>被设计用来读数据的泛型,只能读取类型为T的元素. Lis ...

  6. Python : locals and globals

    Python有两个内置的函数,locals() 和globals(),它们提供了基于字典的访问局部和全局变量的方式.Python使用叫做名字空间的东西来记录变量的轨迹.名字空间只是一个 字典,它的键字 ...

  7. NOIP2017提高组预赛详解

    NOIP2017预赛终于结束了. 普遍反映今年的卷子难度较大,但事实上是这样吗?马上我将为您详细地分析这张试卷,这样你就能知道到底难不难. 对了答案,鄙人考得还是太差了,只有91分. 那么下面我们就一 ...

  8. 网络编程之基于tcp和udp的套接字

    一   udp协议网络编程 DNS:将域名解析成ip地址 SOCK_DGRAM:数据报协议,也是udp协议 udp协议的网络编程的一些用法: recvfrom:接收消息,接收的时一个元组,元组里面的元 ...

  9. 2018.12.05 codeforces 948C. Producing Snow(堆)

    传送门 维护一个堆. 每次先算出一个都不弹掉的总贡献. 然后把要弹掉的弹掉,并减去它们对应的贡献. 代码: #include<bits/stdc++.h> #define ri regis ...

  10. linux vi操作

    1.“i”键,进入编辑状态.可以看到命令的下方出现了“--INSERT--”字样,表示成功进入了编辑模式; 2.“Esc”键,退出编辑模式.并在此时输入“:wq”以退出并保存