-
Notifications
You must be signed in to change notification settings - Fork 181
/
B.cpp
130 lines (114 loc) · 2.12 KB
/
B.cpp
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#include<bits/stdc++.h>
/*Author - Silent Knight
Institution - Birla Institute Of Technology, Mesra
*/
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
ll modInverse(ll n,ll p)
{
ll x = n;
ll y = p-2;
ll res = 1;
x = x % p;
while (y > 0)
{
if (y & 1)
res = (res*x) % p;
y = y>>1;
x = (x*x) % p;
}
return res;
}
ll nCrModPFermat(ll n,ll r,ll p) //if mod value is prime
{
if (r == 0)
return 1;
ll fac[n+1];
fac[0] = 1;
for (ll i=1 ; i<=n; i++)
fac[i] = fac[i-1]*i%p;
return (fac[n]*modInverse(fac[r], p) % p*modInverse(fac[n-r], p) % p) % p;
}
ll nCrModP(ll n,ll r,ll p) //normal iterative solution for all values of mod
{
r = min(r,n-r);
ll c[r+1];
memset(c,0,sizeof(c));
c[0] = 1;
for(ll i=1;i<=n;i++)
{
for(ll j=min(i,r);j>0;j--)
{
c[j] = (c[j] + c[j-1])%p;
}
}
return c[r];
}
void PacalCombinations(ll size)
{
ll a[size][size];
for(ll i=0;i<size;i++)
{
for(ll j=0;j<size;j++)
a[i][j] = 0;
}
a[0][0] = 1;
for(ll i=1;i<size;i++)
{
for(ll j=0;j<=i;j++)
{
if(j == 0 || j == i)
a[i][j] = 1;
else
a[i][j] = a[i-1][j-1] + a[i-1][j];
}
}
}
ll power(ll x, ll y, ll p)
{
ll res = 1;
x = x % p;
while (y > 0)
{
if (y & 1)
res = (res*x) % p;
y = y>>1;
x = (x*x) % p;
}
return res;
}
const ll maxi= 2e5 + 7;
ll a[maxi] = {0};
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t;
cin>>t;
while (t--)
{
ll n,sum = 0;
cin>>n;
if ((n/2)%2 == 1)
{
cout<<"NO"<<"\n";
continue;
}
for (ll i=1;i<=n/2;i++)
{
a[i] = i*2;
sum += a[i];
}
for (ll i=n/2+1;i<n;i++)
{
a[i] = 1+(i - n/2 - 1)*2;
sum -= a[i];
}
cout<<"YES"<<"\n";
for (ll i=1;i<n;i++)
cout<<a[i]<<" ";
cout<<sum<<"\n";
}
}