zoukankan      html  css  js  c++  java
  • 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.

    Sample Input

    Input
    2
    Output
    3
    2 1 2
    Input
    3
    Output
    4
    2 1 3 2


    轰炸坦克。


     1 #include<cstdio>
     2 #include<cstdlib>
     3 #include<cstring>
     4 #include<cmath>
     5 #include<algorithm>
     6 #include<queue>
     7 #include<stack>
     8 #include<deque>
     9 #include<map>
    10 #include<iostream>
    11 using namespace std;
    12 typedef long long  LL;
    13 const double pi=acos(-1.0);
    14 const double e=exp(1);
    15 const int N = 100010;
    16 
    17 #define lson i << 1,l,m
    18 #define rson i << 1 | 1,m + 1,r
    19 
    20 int main()
    21 {
    22     LL n,i,p=0,j;
    23     LL ans=0;
    24     scanf("%lld",&n);
    25     if(n>=4)
    26     {
    27 //        if(n%2==0)
    28 //        {
    29 //            ans=n+(n/2)-1;
    30 //            printf("%lld
    ",ans);
    31 //            for(i=2;i<=n;i+=2)
    32 //                printf("%lld ",i);
    33 //            for(i=1;i<=n;i+=2)
    34 //                printf("%lld ",i);
    35 //            for(i=2;i<n;i+=2)
    36 //                printf("%lld ",i);
    37 //        }
    38             ans=n+(n/2);
    39             printf("%lld
    ",ans);
    40             for(i=2;i<=n;i+=2)
    41                 printf("%lld ",i);
    42             for(i=1;i<=n;i+=2)
    43                 printf("%lld ",i);
    44             for(i=2;i<=n;i+=2)
    45                 printf("%lld ",i);
    46     }
    47     else
    48     {
    49         if(n==2)
    50             printf("3
    2 1 2 ");
    51         if(n==3)
    52             printf("4
    2 1 3 2 ");
    53     }
    54     putchar('
    ');
    55 
    56     return 0;
    57 }
    View Code
  • 相关阅读:
    bug的约束
    bug管理规范
    FTP小教程
    测试需求,产品需求,项目需求
    如何理解客户需求、市场需求、产品需求、业务需求、特性、功能需求 ?(转)
    什么是测试需求?(转)
    绑定与非绑定,反射,内置方法
    面向对象之组合、封装、多态、property装饰器
    面向对象之继承与派生,属性查找
    面向对象基础
  • 原文地址:https://www.cnblogs.com/daybreaking/p/9417799.html
Copyright © 2011-2022 走看看