**
B. Balanced Arraytime
**
**
limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output**
You are given a positive integer nnnn22You want to construct the array aannThe first n2n2aa22the second n2n2aa22all elements of aathe sum of the first half equals to the sum of the second half (∑i=1n2ai=∑i=n2+1nai∑i=1n2ai=∑i=n2+1naiIf there are multiple answers, you can print any. It is not guaranteed that the answer exists.You have to answer ttInputThe first line of the input contains one integer tt1≤t≤1041≤t≤104ttThe only line of the test case contains one integer nn2≤n≤2⋅1052≤n≤2⋅105nn22It is guaranteed that the sum of nn2⋅1052⋅105∑n≤2⋅105∑n≤2⋅105OutputFor each test case, print the answer — “NO” (without quotes), if there is no suitable answer for the given test case or “YES” in the first line and any suitable array a1,a2,…,ana1,a2,…,an1≤ai≤1091≤ai≤109Example
input
2
4
6
8
10
output
NO
YES
2 4 1 5
NO
YES
2 4 6 8 1 3 5 11
NO
源代码:
// An highlighted block
var foo = 'bar';
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<cstdio>
#include <algorithm>
using namespace std;
int main()
{
int t,n,i;
cin>>t;
while(t--)
{
cin>>n;
int ll=n/2,a,p,sum=0,num=0;
if(n==2) {cout<<"NO"<<endl;continue;}
if(ll%2==0){
cout<<"YES"<<endl;
a=2;p=1;
for(i=0;i<ll;i++){
cout<<a<<" ";
sum+=a;
a+=2;
}
for(i=ll;i<n;i++){
cout<<p<<" ";
num+=p;
if(i==n-2)
p=sum-num;
else p+=2;
}
printf("\n");
}
else cout<<"NO"<<endl;
}
return 0;
}