#include <iostream>
using namespace std;
int pot[21];
long long liczby[1048576];
int main()
{
pot[0]=1;
for(int i=1; i < 21; ++i)
{
pot[i]=2*pot[i-1];
}
int n;
long long t;
cin >> n >> t;
for(int i=0; i < pot[n]; ++i)
{
cin >> liczby[i];
}
if(t % 2)
{
for(int i=pot[n] - 1; i >= 0; --i)
{
cout << liczby[i] << " ";
}
}
else
{
for(int i=0; i < pot[n]; ++i)
{
cout << liczby[i] << " ";;
}
}
}
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 | #include <iostream> using namespace std; int pot[21]; long long liczby[1048576]; int main() { pot[0]=1; for(int i=1; i < 21; ++i) { pot[i]=2*pot[i-1]; } int n; long long t; cin >> n >> t; for(int i=0; i < pot[n]; ++i) { cin >> liczby[i]; } if(t % 2) { for(int i=pot[n] - 1; i >= 0; --i) { cout << liczby[i] << " "; } } else { for(int i=0; i < pot[n]; ++i) { cout << liczby[i] << " ";; } } } |
English