#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
int main ()
{
ios_base::sync_with_stdio(0);
vector < int > dane;
int i, n, pp, t, d;
pp = 1;
cin >> n >> t;
for (i=1; i<=n; i++)
{
pp = pp * 2;
};
if (t % 2 == 0)
for (i=1; i<=pp; i++)
{
cin >> d;
cout << d << ' ';
}
else
{
for (i=1; i<=pp; i++)
{
cin >> d;
dane.push_back(d);
};
//wersja 1
// if (n == 1)
// {
// cout << dane[1] << ' ' << dane[0];
// }
// else
// {
// for( size_t i=(pp-1)/2+2; i<=pp; i=i+2)
// cout << dane[i] << ' ' << dane[i-1] << ' ';
// for( size_t i=2-1; i<=pp/2; i=i+2)
// cout << dane[i] << ' ' << dane[i-1] << ' ';
// };
//wersja 2
for( size_t i=pp-1; i>=1; i--)
cout << dane[i] << ' ';
cout << dane[0];
};
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #include <iostream> #include <cstdio> #include <cstring> #include <vector> using namespace std; int main () { ios_base::sync_with_stdio(0); vector < int > dane; int i, n, pp, t, d; pp = 1; cin >> n >> t; for (i=1; i<=n; i++) { pp = pp * 2; }; if (t % 2 == 0) for (i=1; i<=pp; i++) { cin >> d; cout << d << ' '; } else { for (i=1; i<=pp; i++) { cin >> d; dane.push_back(d); }; //wersja 1 // if (n == 1) // { // cout << dane[1] << ' ' << dane[0]; // } // else // { // for( size_t i=(pp-1)/2+2; i<=pp; i=i+2) // cout << dane[i] << ' ' << dane[i-1] << ' '; // for( size_t i=2-1; i<=pp/2; i=i+2) // cout << dane[i] << ' ' << dane[i-1] << ' '; // }; //wersja 2 for( size_t i=pp-1; i>=1; i--) cout << dane[i] << ' '; cout << dane[0]; }; return 0; } |
English