#include <cstdio> using namespace std; const int N = 2000*1000+10; int Res[N]; int main(){ int n,t,i,d,ost; scanf("%d%d", &n,&t); ost = (1<<n)-1; for(i=0; i<(1<<n); i++){ scanf("%d", &d); if(t%2 == 1) Res[ost-i] = d; else Res[i] = d; } for(i=0; i<(1<<n); i++) printf("%d ", Res[i]); printf("\n"); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <cstdio> using namespace std; const int N = 2000*1000+10; int Res[N]; int main(){ int n,t,i,d,ost; scanf("%d%d", &n,&t); ost = (1<<n)-1; for(i=0; i<(1<<n); i++){ scanf("%d", &d); if(t%2 == 1) Res[ost-i] = d; else Res[i] = d; } for(i=0; i<(1<<n); i++) printf("%d ", Res[i]); printf("\n"); return 0; } |