We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d371126 commit fa94eadCopy full SHA for fa94ead
CompetitiveProgramming/CodeChef/P42_POSAND.py
@@ -0,0 +1,36 @@
1
+def main():
2
+ t = int(input())
3
+ res = [2,3,1]
4
+ last = 3
5
+ check = 4
6
+ for _ in range(t):
7
+ n = int(input())
8
+ if n == 1:
9
+ print(1)
10
+ elif (n & (n-1)) == 0:
11
+ print(-1)
12
+ elif n <= last:
13
+ for i in range(n):
14
+ print(res[i], end=" ")
15
+ print()
16
+ else:
17
+ for i in range(last):
18
19
+ last += 1
20
+ while last <= n:
21
+ if last == check:
22
+ res.append(last + 1)
23
+ res.append(last)
24
+ print((last + 1), end=" ")
25
+ print(last, end=" ")
26
+ last += 2
27
+ check *= 2
28
29
30
31
32
33
+ last -= 1
34
+ return 0
35
+
36
+main()
0 commit comments