【Codeforces Round #442 (Div. 2) C】Slava and tanks
【链接】 我是链接,点我呀:)
【题意】
【题解】
在2,4,6...轰炸 然后在1,3,5...轰炸 最后在2,4,6轰炸。 可以保证每个tank都被炸死。【代码】
#include <bits/stdc++.h>
using namespace std;
int n,flag;
vector <int> ans;
int main(){
// freopen("rush.txt","r",stdin);
scanf("%d",&n);
flag = n&1;
if (flag==0){
for (int i = 1;i <= n;i+=2)
ans.push_back(i);
for (int i = 2;i <= n;i+=2)
ans.push_back(i);
for (int i = 1;i <= n;i+=2)
ans.push_back(i);
}else{
for (int i = 2;i <= n;i+=2)
ans.push_back(i);
for (int i = 1;i <= n;i+=2)
ans.push_back(i);
for (int i = 2;i <= n;i+=2)
ans.push_back(i);
}
printf("%d\n",(int) ans.size());
for (int i = 0;i <(int) ans.size();i++)
printf("%d ",ans[i]);
puts("");
return 0;
}