#include <cstdio> #include <cmath> const int MX = 1024 * 1024; int n, t, a[MX]; int main() { scanf("%d%d", &n, &t); int numCards = 1 << n; for (int i = 0; i < numCards; ++i) { scanf("%d", &a[i]); } if (t % 2) { for (int i = numCards - 1; i >= 0; --i) printf("%d ", a[i]); } else { for (int i = 0; i < numCards; ++i) printf("%d ", a[i]); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <cstdio> #include <cmath> const int MX = 1024 * 1024; int n, t, a[MX]; int main() { scanf("%d%d", &n, &t); int numCards = 1 << n; for (int i = 0; i < numCards; ++i) { scanf("%d", &a[i]); } if (t % 2) { for (int i = numCards - 1; i >= 0; --i) printf("%d ", a[i]); } else { for (int i = 0; i < numCards; ++i) printf("%d ", a[i]); } } |