#include<bits/stdc++.h>
using namespace std;
int n, t, pot;
long long a[1050000];
int main()
{
scanf("%d%d", &n, &t);
pot=1;
for(int i=1; i<=n; i++){
pot*=2;
}
//printf("%lld\n", pot);
for(int i=1; i<=pot; i++){
scanf("%lld", &a[i]);
if(t%2==0) printf("%d ", a[i]);
}
if(t%2==1){
for(int i=pot; i>=1; i--){
printf("%lld ", a[i]);
}
}
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include<bits/stdc++.h> using namespace std; int n, t, pot; long long a[1050000]; int main() { scanf("%d%d", &n, &t); pot=1; for(int i=1; i<=n; i++){ pot*=2; } //printf("%lld\n", pot); for(int i=1; i<=pot; i++){ scanf("%lld", &a[i]); if(t%2==0) printf("%d ", a[i]); } if(t%2==1){ for(int i=pot; i>=1; i--){ printf("%lld ", a[i]); } } } |
English