输入样例:
8
91 71 2 34 10 15 55 18
输出样例:
18 34 55 71 2 10 15 91
答案
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
const int N = 1e6 + 10;
using namespace std;
int n;
int dp[N];
void create(int x){
if(x>n) return ;
create(2*x);
create(2*x+1);
cin>>dp[x];
}
int main(){
cin>>n;
create(1);
for(int i=1;i<=n;i++){
if(i==n) cout<<dp[i]<<endl;
else cout<<dp[i]<<" ";
}
return 0;
}