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的更多相关文章
随机推荐
- (转)android权限(permission)大全
文章转载自:http://blog.csdn.net/hai_qing_xu_kong/article/details/24265533 1.android.permission.WRITE_USER ...
- yum 安装 php7 ,lamp ,以及安装swoole
1 更新yum yum update 2 安装依赖 yum -y install pcre* openssl* yum -y install gcc make gd-devel libjpeg-dev ...
- 大数乘法java版
import java.util.*; import java.math.*; public class NumMul{ public static void main(String args[]){ ...
- iOS.UI.UIWindow
UIWindow 1. UIWindow 2. UIWindow的使用场景 2.1 额外添加的Window需要手动进行旋转 最近有遇到一个UIWindow的使用场景:在ApplicationDeleg ...
- XiaoKL学Python(C)__future__
__future__ in Python 1. from __future__ import xxxx 这是为了在低版本的python中使用可能在某个高版本python中成为语言标准的特性,从而 在将 ...
- RNA测序相对基因表达芯片有什么优势?
RNA测序相对基因表达芯片有什么优势? RNA-Seq和基因表达芯片相比,哪种方法更有优势?关键看适用不适用.那么RNA-Seq适用哪些研究方向?是否您的研究?来跟随本文了解一下RNA测序相对基因表达 ...
- Python之路(第二篇):Python基本数据类型字符串(一)
一.基础 1.编码 UTF-8:中文占3个字节 GBK:中文占2个字节 Unicode.UTF-8.GBK三者关系 ascii码是只能表示英文字符,用8个字节表示英文,unicode是统一码,世界通用 ...
- sqli-labs:5-6,盲注
思考1:当# --+都被过滤时,只能考虑闭合处理 思考2:union联合注入时必须先判断字段长度 eg. id=1' order by 3 and '1'='1 sqli5: 首先判断出对id经过了' ...
- Spring 常见注解
@Component:标准一个普通的spring Bean类. @Controller:标注一个控制器组件类. @Service:标注一个业务逻辑组件类. @Repository:标注一个DAO组件类 ...
- .NET获取城市信息(将三字代码转换成城市名)
整理代码,发现有一个从两张表里读取城市列表,然后linq和lambda表达式来获取城市名的函数,代码如下: public static string GetCityHotelText(string c ...