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
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int potega(int a, int b)
{
    int c = a;
    for(int i = 1; i < b; i++)
        c *= a;
    return c;
}
long long a;
long long b[1000000];
long long c;
int main()
{
    scanf("%d%lld",&a,&c);
    for(int i = 0; i < potega(2,a); i++)
    {
        scanf("%lld",&b[i]);
    }
    if(c%2!=0)
    {
        reverse(b,b+potega(2,a));
        for(int i = 0; i < potega(2,a);i++)
            printf("%lld ",b[i]);
    }
    else
         for(int i = 0; i < potega(2,a);i++)
            printf("%lld ",b[i]);
}