Slava and tanks(CodeForces - 877C)

第五次个人赛

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 

题意:炸坦克,一个坦克两条命, 输入一个数n,n代表有n个位置,每个位置可能有坦克,可能也没有坦克,一个坦克要炸两次才能毁掉,若这个位置有坦克,在这个位置炸一下,这个位置的坦克就会跑到左右相邻的其中一个位置,要把所有坦克都炸毁,求最小的轰炸数;

其他大神分析:我们可以先对偶数位的格子投放炸弹,此时被炸的坦克一定会移向奇数位的格子,之后对奇数位的格子投放炸弹,之前移过来的坦克已损毁,但初始位于奇数位的坦克会移向偶数位的格子,我们再对偶数位的格子投放炸弹。这时所有坦克无论在哪都必定损毁。

思路:题目给了1~n的格子,格子的偶数一定小于等于奇数,例如5,奇数1,3,5,偶数2,4;例如4,奇数2,4,偶数1,3,那么我们可以以5个格子进行分析,我们为什么不炸奇偶奇,而选择偶奇偶,炸奇偶奇有3+2+3次,炸偶奇偶有2+3+2次,题中要求最小的轰炸数,所以我们选择偶奇偶

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <cstring>
using namespace std;
typedef long long LL;
int main()
{
    int n,i;
    scanf("%d",&n);
    printf("%d\n",n+n/2);
    for(i=2; n>=i; i=i+2)
    {
        printf("%d ",i);
    }
    for(i=1; n>=i; i=i+2)
    {
        printf("%d ",i);
    }
    for(i=2; n>=i; i=i+2)
    {
        printf("%d ",i);
    }
    return 0;
}

 

1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值