#include <iostream>
using namespace std;
int pot(int n)
{
int w = 1,a=2;
while(n>0)
{
if (n%2 == 1)
w *= a;
a*=a;
n/=2;
}
return w;
}
int T[2*1000*1000];
int main()
{
ios_base::sync_with_stdio(0);
int n,k;
cin >> n >> k;
int wyn = pot(n);
for(int i=0;i<wyn;i++)
cin >> T[i];
if(k%2==0)
{
for(int i=0;i<wyn;i++)
cout << T[i] << " ";
}
else
{
for(int i=wyn-1;i>=0;i--)
cout << T[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 28 29 30 31 32 33 34 35 36 | #include <iostream> using namespace std; int pot(int n) { int w = 1,a=2; while(n>0) { if (n%2 == 1) w *= a; a*=a; n/=2; } return w; } int T[2*1000*1000]; int main() { ios_base::sync_with_stdio(0); int n,k; cin >> n >> k; int wyn = pot(n); for(int i=0;i<wyn;i++) cin >> T[i]; if(k%2==0) { for(int i=0;i<wyn;i++) cout << T[i] << " "; } else { for(int i=wyn-1;i>=0;i--) cout << T[i] << " "; } return 0; } |
English