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

int main(void)
{
	int n;
	long int t, m;
	scanf("%d %ld", &n, &t);
	m = 1UL << n;
	t %= 2;
	long int *p;
	p = malloc(m * sizeof(long int));
	size_t i;
	for (i = 1; i <= m; i++)
	{
		scanf("%ld", p+i-1);
		if (!t)
			printf("%ld%c", p[i-1], i < m ? ' ' : '\n');
	}
	if(t)
		for (i = m; i; i--)
			printf("%ld%c", p[i-1], i - 1 ? ' ' : '\n');
	free(p);
	return 0;
}