#include<cstdio> using namespace std; const int size = 1<<20; int n,t; int tablica [size+7]; int main(){ scanf("%d %d",&n,&t); n = 1<<n; for(int i=1;i<=n;i++){ scanf("%d",&tablica[i]); } if(t%2==1){ for(int i=n;i>=1;i--){ printf("%d ",tablica[i]); } } else{ for(int i=1;i<=n;i++){ printf("%d ",tablica[i]); } } 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 25 26 27 | #include<cstdio> using namespace std; const int size = 1<<20; int n,t; int tablica [size+7]; int main(){ scanf("%d %d",&n,&t); n = 1<<n; for(int i=1;i<=n;i++){ scanf("%d",&tablica[i]); } if(t%2==1){ for(int i=n;i>=1;i--){ printf("%d ",tablica[i]); } } else{ for(int i=1;i<=n;i++){ printf("%d ",tablica[i]); } } return 0; } |