#include <bits/stdc++.h>
using namespace std;
int tab[1048579];
int main()
{
long long int num, tas;
scanf("%lld %lld", &num, &tas);
int licz = pow(2, num);
for(int i = 0 ; i < licz; i++)
scanf("%d", &tab[i]);
if(tas%2==0)
{
for(int i = 0 ; i < licz; i++)
printf("%d ", tab[i]);
return 0;
}
else
{
for(int i = 0 ; i < licz; i++)
printf("%d ", tab[licz-i-1]);
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 | #include <bits/stdc++.h> using namespace std; int tab[1048579]; int main() { long long int num, tas; scanf("%lld %lld", &num, &tas); int licz = pow(2, num); for(int i = 0 ; i < licz; i++) scanf("%d", &tab[i]); if(tas%2==0) { for(int i = 0 ; i < licz; i++) printf("%d ", tab[i]); return 0; } else { for(int i = 0 ; i < licz; i++) printf("%d ", tab[licz-i-1]); return 0; } } |
English