-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathposand.cpp
More file actions
57 lines (57 loc) · 994 Bytes
/
posand.cpp
File metadata and controls
57 lines (57 loc) · 994 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include<bits/stdc++.h>
using namespace std;
int other(int x)
{
if(x==0)
return false;
return (log10(x) / log10(2));
}
int another(int n)
{
return (ceil(log2(n))==floor(log2(n)));
}
int main()
{
int t;
cin>>t;
for(int j=0;j<t;j++)
{
int n;
cin>>n;
list <int> g;
if(n==1)
{
g.push_back(1);
}
if(another(n) && (n!=1))
{
cout<<"-1"<<endl;
}
if(n>=3)
{
g.push_back(2);
g.push_back(3);
g.push_back(1);
}
if(n>3 && (!(another(n))))
{
int i=4;
while(i<=n)
{
if(another(i))
{
g.push_back(i+1);
g.push_back(i);
i=i+2;
}
else
g.push_back(i);
i++;
}
}
list <int> :: iterator it;
for(it = g.begin(); it != g.end(); ++it)
cout << '\t' << *it;
cout << '\n';
}
}