fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7. if (n==2 || n==3) {
  8. cout << "NO SOLUTION";
  9. return 0;
  10. }
  11. for (int i=n-(n%2==1);i>=2;i-=2) {
  12. cout << i << " ";
  13. }
  14. for (int i=n-(n%2==0);i>=1;i-=2) {
  15. cout << i << " ";
  16. }
  17. }
Success #stdin #stdout 0.01s 5292KB
stdin
5
stdout
4 2 5 3 1