#include void solve(int s, int t) { using namespace std; int mid = s + (t - s) / 2; if (t == s) { //cout << mid << " "; cout << s << " "; return; } else if (t - s == 1) { cout << s << " " << t << " "; } else { cout << mid << " "; solve(s, mid - 1); solve(mid + 1, t); } } int main() { // 数列の端で高さを揃えて残りで平衡二分木を作成すれば良い. using namespace std; int k; int n = 1; cin >> k; for (int i = 0; i < k; i++) { n *= 2; } n -= 1; int r = (3 * k + 1) >= n ? n : (3 * k + 1) ; // r >= 3 は保証される. for (int i = n - r + 1; i <= n; i++) { cout << i << " "; } if (n - r > 0) solve(1, n - r); cout << endl; }