#include <cstdio> using namespace std; typedef unsigned int uint_t; const static uint_t MAX_N = 1048576; uint_t A[MAX_N]; int main() { uint_t n, t, a, m; bool reverse; scanf("%u %u", &n, &t); m = 1U << n; reverse = t & 1; if (!reverse) { for (uint_t i = 0; i < m; ++i) { scanf("%u", &a); printf("%u ", a); } } else { for (uint_t i = 0; i < m; ++i) scanf("%u", A + i); while (m--) printf("%u ", A[m]); } 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 | #include <cstdio> using namespace std; typedef unsigned int uint_t; const static uint_t MAX_N = 1048576; uint_t A[MAX_N]; int main() { uint_t n, t, a, m; bool reverse; scanf("%u %u", &n, &t); m = 1U << n; reverse = t & 1; if (!reverse) { for (uint_t i = 0; i < m; ++i) { scanf("%u", &a); printf("%u ", a); } } else { for (uint_t i = 0; i < m; ++i) scanf("%u", A + i); while (m--) printf("%u ", A[m]); } return 0; } |