#include <cstdio> #include <cmath> using namespace std; const int MAXSIZE = 1048756; int main() { int n, t; unsigned long long int tab[1048756]; scanf("%d %d", &n, &t); int size = pow(2, n); for (size_t i = 0; i < size; i++) { scanf("%d", &tab[i]); } if (t % 2 == 0) { for (int i = 0; i < size; i++) { printf("%d ", tab[i]); } } else { for (int i = (size - 1); i >= 0; i--) { printf("%d ", tab[i]); } } }
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 | #include <cstdio> #include <cmath> using namespace std; const int MAXSIZE = 1048756; int main() { int n, t; unsigned long long int tab[1048756]; scanf("%d %d", &n, &t); int size = pow(2, n); for (size_t i = 0; i < size; i++) { scanf("%d", &tab[i]); } if (t % 2 == 0) { for (int i = 0; i < size; i++) { printf("%d ", tab[i]); } } else { for (int i = (size - 1); i >= 0; i--) { printf("%d ", tab[i]); } } } |