Codeforces Round #636 (Div. 3) B. Balanced Array

http://codeforces.com/contest/1343/problem/B

分别构造偶数和奇数序列,最后一个位置用来补充不足的数

 1 //
 2 // Created by w on 2021/1/8.
 3 //
 4 
 5 #include <iostream>
 6 using namespace  std;
 7 int main()
 8 {
 9     int t;
10     cin>>t;
11     while (t--)
12     {
13         int n;
14         cin>>n;
15         if(n%4==2)
16         {
17             cout<<"NO"<<endl;
18             continue;
19         } else
20         {
21             cout<<"YES"<<endl;
22             for(int i=1;i<=n/2;i++)
23                 printf("%d ",i<<1);
24             for(int i=1;i<n/2;i++)
25                 printf("%d ",(i<<1)-1);
26             printf("%d\n",n+n/2-1);
27         }
28     }
29     return  0;
30 }

 

posted @ 2021-01-08 00:49  BlackSnow  阅读(75)  评论(0)    收藏  举报