#include <cstdio> using namespace std; int main() { unsigned int n; unsigned int np = 1; unsigned int t; unsigned int a[1048580]; unsigned int *p; scanf("%u %u\n", &n, &t); for (int i = 0; i < n; i++) np *= 2; p = a; for (unsigned int i = 0; i < np; i++) { scanf("%u", p++); } if (t % 2 == 0) { p = a; for (unsigned int i = 0; i < np-1; i++) { printf("%u ", *p); p++; } printf("%u\n", *p); } else { p = &a[np-1]; for (unsigned int i = 0; i < np-1; i++) { printf("%u ", *p); p--; } printf("%u\n", *p); } 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 | #include <cstdio> using namespace std; int main() { unsigned int n; unsigned int np = 1; unsigned int t; unsigned int a[1048580]; unsigned int *p; scanf("%u %u\n", &n, &t); for (int i = 0; i < n; i++) np *= 2; p = a; for (unsigned int i = 0; i < np; i++) { scanf("%u", p++); } if (t % 2 == 0) { p = a; for (unsigned int i = 0; i < np-1; i++) { printf("%u ", *p); p++; } printf("%u\n", *p); } else { p = &a[np-1]; for (unsigned int i = 0; i < np-1; i++) { printf("%u ", *p); p--; } printf("%u\n", *p); } return 0; } |