#include <cstdio>
#include <cmath>
using namespace std;
int tab[2097152];
int main(){
unsigned int n, m;
scanf("%u %u", &n, &m);
for(int x=0; x<pow(2, n); x++){
scanf("%d", &tab[x]);
}
if(m % 2 == 1){
for(int x = pow(2, n)-1; x>=0; x--){
printf("%d ", tab[x]);
}
} else {
for(int x=0; x<pow(2, n); x++){
printf("%d ", tab[x]);
}
}
printf("\n");
}
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 | #include <cstdio> #include <cmath> using namespace std; int tab[2097152]; int main(){ unsigned int n, m; scanf("%u %u", &n, &m); for(int x=0; x<pow(2, n); x++){ scanf("%d", &tab[x]); } if(m % 2 == 1){ for(int x = pow(2, n)-1; x>=0; x--){ printf("%d ", tab[x]); } } else { for(int x=0; x<pow(2, n); x++){ printf("%d ", tab[x]); } } printf("\n"); } |
English