#include <cstdio>
#include <cmath>
#define MAXN 2097152
int n,t;
int tab[MAXN];
int main() {
scanf("%d%d",&n,&t);
for(int k = 0;k < pow(2,n);k++)
scanf("%d",&tab[k]);
if(t % 2 == 1)
for(int k = pow(2,n)-1;k >= 0;k--)
printf("%d ",tab[k]);
else
for(int k = 0;k < pow(2,n);k++)
printf("%d ",tab[k]);
printf("\n");
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <cstdio> #include <cmath> #define MAXN 2097152 int n,t; int tab[MAXN]; int main() { scanf("%d%d",&n,&t); for(int k = 0;k < pow(2,n);k++) scanf("%d",&tab[k]); if(t % 2 == 1) for(int k = pow(2,n)-1;k >= 0;k--) printf("%d ",tab[k]); else for(int k = 0;k < pow(2,n);k++) printf("%d ",tab[k]); printf("\n"); } |
English