#include <cstdio> #include <vector> using namespace std; int n,t,goal,ai; vector < int > result; int main () { scanf("%d%d",&n,&t); goal = 1; for (int i = 0; i < n; ++i) goal *= 2; for (int i = 1; i <= goal; ++i) { scanf("%d",&ai); result.push_back(ai); } if (t % 2 == 0) for(int i = 0; i < (int)result.size(); ++i) printf("%d ", result[i]); else for (int i= result.size()-1; i >= 0; --i) printf("%d ", result[i]); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #include <cstdio> #include <vector> using namespace std; int n,t,goal,ai; vector < int > result; int main () { scanf("%d%d",&n,&t); goal = 1; for (int i = 0; i < n; ++i) goal *= 2; for (int i = 1; i <= goal; ++i) { scanf("%d",&ai); result.push_back(ai); } if (t % 2 == 0) for(int i = 0; i < (int)result.size(); ++i) printf("%d ", result[i]); else for (int i= result.size()-1; i >= 0; --i) printf("%d ", result[i]); return 0; } |