#include <algorithm> #include <cstdint> #include <iostream> #define N(x) (1 << x) int main(void) { int64_t n, t; scanf("%lld %lld", &n, &t); int64_t a[N(n)]; for (size_t i = 0; i < N(n); i++) scanf("%lld", &a[i]); if (t % 2 == 1) for (size_t i = N(n) - 1; i != -1; i--) printf("%lld ", a[i]); else for (size_t i = 0; i < N(n); i++) printf("%lld ", a[i]); 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 | #include <algorithm> #include <cstdint> #include <iostream> #define N(x) (1 << x) int main(void) { int64_t n, t; scanf("%lld %lld", &n, &t); int64_t a[N(n)]; for (size_t i = 0; i < N(n); i++) scanf("%lld", &a[i]); if (t % 2 == 1) for (size_t i = N(n) - 1; i != -1; i--) printf("%lld ", a[i]); else for (size_t i = 0; i < N(n); i++) printf("%lld ", a[i]); return 0; } |