fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define el "\n"
  4. #define ll long long
  5. #define ull unsigned long long
  6. #define se second
  7. #define fi first
  8. #define be begin()
  9. #define en end()
  10. #define Faster cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
  11.  
  12. int main()
  13. {
  14. Faster;
  15. int n; cin >> n;
  16. if(n % 2 || n == 2)
  17. {
  18. cout << "No";
  19. return 0;
  20. }
  21. else
  22. {
  23. int sum = 0;
  24. for(int i = 2; i <= n; i += 2)
  25. {
  26. cout << i << " ";
  27. sum += i;
  28. }
  29. for(int i = 1; i < n - 1; i+= 2)
  30. {
  31. cout << i << " ";
  32. sum -= i;
  33. }
  34. cout << sum;
  35. }
  36. return 0;
  37. }
  38.  
Success #stdin #stdout 0.01s 5284KB
stdin
4
stdout
2 4 1 5