#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
int main() {
int n, t;
scanf("%i %i", &n, &t);
int c=pow(2,n);
int A[c];
for(int x=0; x<c; x++) {
scanf("%i", &A[x]);
}
if(t%2==0) {
for(int x=0; x<c; x++) {
printf("%i ", A[x]);
}
} else {
for(int x=c-1; x>=0; x--) {
printf("%i ", A[x]);
}
}
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 | #include <cstdio> #include <cstdlib> #include <cmath> using namespace std; int main() { int n, t; scanf("%i %i", &n, &t); int c=pow(2,n); int A[c]; for(int x=0; x<c; x++) { scanf("%i", &A[x]); } if(t%2==0) { for(int x=0; x<c; x++) { printf("%i ", A[x]); } } else { for(int x=c-1; x>=0; x--) { printf("%i ", A[x]); } } return 0; } |
English