题目来源
https://codeforces.com/problemset/problem/1352/G
题目描述

AC题解
做的时候什么也想不到,看了别人的思路才发现自己太傻了,原来这道题能这么简单。
n<=3的时候不能构成,当n>=4的时候,先降序放奇数,放完后从 4 , 2 开始,然后升序放偶数即可。
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int T;
scanf("%d", &T);
while (T--) {
int n;
scanf("%d", &n);
if (n <= 3) {
puts("-1");
}
else {
for (int i = n; i >= 1; --i)
{
if (i & 1)
printf("%d ", i);
}
printf("4 2 ");
for (int i = 6; i <= n; i += 2)
printf("%d ", i);
puts("");
}
}
return 0;
}
这篇文章是关于解决Codeforces平台上一道题目(编号1352/G)的AC题解,涉及将数字按照奇数降序、偶数升序的顺序排列,当输入n大于等于4时的解决方案。
329

被折叠的 条评论
为什么被折叠?



