http://codeforces.com/contest/877/problem/C
题意:1~n上每个位置有一些坦克,你可以在任意位置丢炸弹,当你在x位置丢炸弹时,x上的坦克会跑到x-1和x+1位置上,每个坦克需要炸两次,问最小次数炸毁所有坦克的方法
自己做的时候没想到…
思路:既然他会往左右跑,那么一开始炸偶数点,让它们跑到奇数点,再炸一次奇数点,它又会跑到偶数点,再炸一次偶数点…
#include<bits/stdc++.h>
#define fi first
#define se second
#define log2(a) log(n)/log(2)
#define show(a) cout<<a<<endl;
#define show2(a,b) cout<<a<<" "<<b<<endl;
#define show3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl;
#define tim printf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
using namespace std;
typedef long long ll;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<P, ll> LP;
const ll inf = 1e18;
const int N = 2e6 + 10;
const ll mod = 1e9+7;
const int base = 131;
const double pi = acos ( -1 );
const double eps = 1e-8;
inline ll mul(ll x,ll y) { return (x*y-(ll)((long double)x*y/mod)*mod+mod)%mod;}
inline ll ksm(ll a,ll b) {ll ans=1;while(b){if(b&1)ans=mul(ans,a);a=mul(a,a),b>>=1;}return ans;}
#define a(i,j) a[(i-1)*m+(j)]
#define b(i,j) b[(i-1)*m+(j)]
unordered_map<ll, ll> mp;
ll n, m,sx,sy,x,y,z,ex,ey,k,a[N],b[N],c[N];
ll ans,t,flag;
ll num[1005][1005],vis[1005][1005];
vector<ll> v;
ll sum,cnt;
ll res[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n;
if(n==2)
{
cout<<3<<endl<<"2 1 2";
}
else
{
cout<<2*(n/2)+(n+1)/2<<endl;
for(int i=2;i<=n;i+=2) cout<<i<<" ";
for(int i=1;i<=n;i+=2) cout<<i<<" ";
for(int i=2;i<=n;i+=2) cout<<i<<" ";
}
}