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