Advertisement
ivangarvanliev

Untitled

Jun 3rd, 2024
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int n;
  6.     cin >> n;
  7.  
  8.     if (n == 1) {
  9.         cout << "1";
  10.         return 0;
  11.     }
  12.  
  13.     if (n <= 3) {
  14.         cout << "NO SOLUTION";
  15.         return 0;
  16.     }
  17.     vector<int> permutation;
  18.     for (int i = 2; i <= n; i += 2) {
  19.         permutation.push_back(i);
  20.     }
  21.     for (int i = 1; i <= n; i += 2) {
  22.         permutation.push_back(i);
  23.     }
  24.     for (int i = 0; i < n; ++i) {
  25.         cout << permutation[i] << " ";
  26.     }
  27.     cout << endl;
  28.  
  29.     return 0;
  30. }
  31.  
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement