fork download
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. typedef long long ll;
  5. int main()
  6. {
  7. #ifndef ONLINE_JUDGE
  8. freopen("input.txt", "r", stdin);
  9. freopen("output.txt", "w", stdout);
  10. #endif
  11.  
  12. ll t;
  13. cin >> t;
  14. while (t--)
  15. {
  16. ll a;
  17. cin >> a;
  18. if (a != 0 && (a & (a - 1)) == 0)
  19. {
  20. cout << -1 <<endl;
  21. continue;
  22.  
  23. }
  24. else if (a == 1)
  25. {
  26. cout << 1 <<endl;
  27. continue;
  28. }
  29. else if (a==3)
  30. {
  31. cout << 2 << " " << 3 << " " << 1 <<endl;
  32. continue;
  33. }
  34. else if (a==5)
  35. {
  36. cout << 2 << " " << 3 << " " << 1 << " "<<5<<" "<<4 <<endl;
  37. continue;
  38. }
  39. else
  40. {
  41. cout << 2 << " " << 3 << " " << 1 << " "<<5<<" "<<4<<endl;
  42. ll i=6;
  43. while(i<=a)
  44. {
  45. if ( i != 0 && (i & (i - 1)) == 0)
  46. {
  47. cout << i + 1 << " " << i << " ";
  48. i += 2;
  49. }
  50. else
  51. {
  52. cout << i << " ";
  53. i++;
  54. }
  55. }
  56. }
  57. cout << endl;
  58.  
  59.  
  60. }
  61. }
  62.  
Success #stdin #stdout 0s 4244KB
stdin
1
1
stdout
-1