-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB_Balanced_Array.cpp
More file actions
43 lines (42 loc) · 946 Bytes
/
B_Balanced_Array.cpp
File metadata and controls
43 lines (42 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 100000005;
vector<bool> p(MAXN, false);
vector<ll> prime;
#define fastio \
{ \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
}
int main()
{
fastio
ll t,
c = 0;
cin >> t;
while (t--)
{
ll n;
cin >> n;
if (n == 2 || n / 2 % 2)
cout << "NO\n";
else
{
ll sum = 0, sum2 = 0;
cout << "YES\n";
for (ll i = 2; i <= n; i += 2)
{
cout << i << " ";
sum += i;
}
for (ll i = 1; i < n - 2; i += 2)
{
cout << i << " ";
sum2 += i;
}
cout << sum - sum2 << endl;
// cout << endl;
}
}
}