codeforces877c
2 seconds
256 megabytes
standard input
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.
The first line contains a single integer n (2 ≤ n ≤ 100 000) — the size of the map.
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.
2
3
2 1 2
3
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的更多相关文章
随机推荐
- css font-size=0的妙用
转自:css font-size=0有什么妙用? 回答一: 问题的根源是 inline(a标签默认是display:inline) 和 inline-block (.list-info 设置的是 di ...
- 02. pt-archiver
pt-archiver \--source h=192.168.100.101,P=3306,u=admin,p='admin',D=db01,t=t01 \--dest h=192.168.100. ...
- PHD实时数据对象
PHD实时数据库在化工制造业的应用 PISDK 开发包 电力企业信息化
- sqli-labs:11-16,post注入
sqli11: post:uname=xx' order by 2#&passwd=bla&submit=Submit(判定字段为2) 解释下为什么结果不是admin,这是sql执行的 ...
- idea部署tomcat-404错误
今天在部署数据质量web工程在tomcat后,访问时报404错误,在网上搜了很多相关配置,也都是一步一步来的 Application Context 也配置好了,Artifact也添加了,就是访问不了 ...
- mysql如何查看自己数据库文件所在的位置
mysql如何查看自己数据库文件所在的位置 C:\Program Files\MySQL\MySQL Server 5.5 mysql数据库 方法/步骤 第1步: 打开mysqml文件夹,显示 ...
- DB2有五种约束
DB2有五种约束: NOT NULL 约束是这样一种规则,它防止在表的一列或多列中输入空值. 唯一约束(也称为唯一键约束)是这样一种规则,它禁止表的一列或多列中出现重复值.唯一键和主键是受支持的唯一约 ...
- pygame小记
pygame.display.set_mode(x, y)设置显示窗口大小pygame.sprite.Sprite方法中有image, rect, speed等参数 其中image 可以通过 pyga ...
- 【Web】CSS实现绝对定位元素水平垂直居中
网页中常常需用让绝对定位元素水平垂直居中,下面介绍2种方法: 一 元素宽度未知 <!DOCTYPE html> <html lang="en"> <h ...
- python ui学习过程,使用pyqt5实现
首先安装pyqt5的包,然后打开notebook就可以编写了.当然这样编写,也可以用designer进行. 它是pyqt5-tools的一个exe软件,\Anaconda3\Lib\site-pack ...