#include <stdio.h> int n, t, a[1<<20], i; int main() { scanf("%d%d", &n,&t); n = 1<<n; for (i=0; i<n; i++) scanf("%d", &a[i]); if (t%2) for (i=n-1; i>=0; i--) printf("%d ", a[i]); else for (i=0; i<n; i++) printf("%d ", a[i]); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 | #include <stdio.h> int n, t, a[1<<20], i; int main() { scanf("%d%d", &n,&t); n = 1<<n; for (i=0; i<n; i++) scanf("%d", &a[i]); if (t%2) for (i=n-1; i>=0; i--) printf("%d ", a[i]); else for (i=0; i<n; i++) printf("%d ", a[i]); return 0; } |