【Codeforces Round #442 (Div. 2) C】Slava and tanks
and Codeforces div round
2023-09-14 09:03:45 时间
【链接】 我是链接,点我呀:)
【题意】
【题解】
在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;
}
相关文章
- 【Codeforces Round #635 (Div. 2) C】Linova and Kingdom
- 【Codeforces 1042D】Petya and Array
- 【Educational Codeforces Round 53 (Rated for Div. 2) C】Vasya and Robot
- 【Educational Codeforces Round 48 (Rated for Div. 2) D】Vasya And The Matrix
- 【Divide by Zero 2017 and Codeforces Round #399 (Div. 1 + Div. 2, combined) B】 Code For 1
- 【ICM Technex 2018 and Codeforces Round #463 (Div. 1 + Div. 2, combined) D】Tree
- 【Codeforces Round #457 (Div. 2) C】Jamie and Interesting Graph
- 【Codeforces Round #457 (Div. 2) A】 Jamie and Alarm Snooze
- 【Codeforces Round #445 (Div. 2) C】 Petya and Catacombs
- 【Codeforces Round #299 (Div. 2) E】Tavas and Pashmaks
- 【29.89%】【codeforces 734D】Anton and Chess
- 【codeforces 791A】Bear and Big Brother
- 【codeforces 761D】Dasha and Very Difficult Problem
- 【codeforces 761E】Dasha and Puzzle
- 【Codeforces Round #430 (Div. 2) D】Vitya and Strange Lesson
- 【Codeforces Round #430 (Div. 2) C】Ilya And The Tree
- 【Codeforces Round #429 (Div. 2) C】Leha and Function
- 【Codeforces Round #425 (Div. 2) B】Petya and Exam
- 【Codeforces Round #421 (Div. 2) B】Mister B and Angle in Polygon
- 【Codeforces Round #421 (Div. 2) A】Mister B and Book Reading
- Codeforces Round #252 (Div. 2) B. Valera and Fruits(模拟)
- C. Arthur and Table(Codeforces Round #311 (Div. 2) 贪心)
- Codeforces 439D Devu and his Brother 三分
- CodeForces 558C Amr and Chemistry (位运算,数论,规律,枚举)
- Codeforces Round #216 (Div. 2) E. Valera and Queries (BIT)
- Codecraft-18 and Codeforces Round #458 (Div. 1 + Div. 2, combined)
- Codeforces Round #410 (Div. 2) A. Mike and palindrome