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 <stdio.h>
#include <math.h>

int main(){
	unsigned int n, n2, t, p, i;
	int *tab = new int[1048576];

	scanf("%u %u", &n, &t);
	n2 = pow(2,n);
	if (0 == t%2)
	{
		for (i=0; i<n2; i++)
		{
			scanf("%u", &p);
			printf("%u ", p);
		}
	}
	else
	{
		
		for (i=0; i<n2; i++)
		{
			scanf("%u", &tab[i]);
		}
		for (i=n2; i>0; i--)
		{
			printf("%u ", tab[i-1]);	
		}
	}
	return 0;
}