#include <stdio.h> #include <math.h> int main(int, char **) { int n, t; scanf("%d %d", &n, &t); const int n_pow = pow(2.0, n); int *array = new int[n_pow]; for (int i=0; i<n_pow; ++i) scanf("%d", &array[i]); if (t % 2 == 0) for (int i=0; i<n_pow; ++i) printf("%d ", array[i]); else for (int i=n_pow-1; i>=0; --i) printf("%d ", array[i]); printf("\n"); delete [] array; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <stdio.h> #include <math.h> int main(int, char **) { int n, t; scanf("%d %d", &n, &t); const int n_pow = pow(2.0, n); int *array = new int[n_pow]; for (int i=0; i<n_pow; ++i) scanf("%d", &array[i]); if (t % 2 == 0) for (int i=0; i<n_pow; ++i) printf("%d ", array[i]); else for (int i=n_pow-1; i>=0; --i) printf("%d ", array[i]); printf("\n"); delete [] array; return 0; } |