#include <stdio.h> #include <stdlib.h> #define MAXN 2000000 long long buf[MAXN]; int main(int argc, const char* argv[]) { int n, i; long long t, nn; scanf("%d %lld", &n, &t); nn = (((long long) 1) << n); for (i=0;i<nn;i++) scanf("%lld", &buf[i]); if (t%2==0) for (i=0;i<nn;i++) printf("%lld ", buf[i]); else for (i=nn-1;i>=0;i--) printf("%lld ", buf[i]); printf("\n"); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <stdio.h> #include <stdlib.h> #define MAXN 2000000 long long buf[MAXN]; int main(int argc, const char* argv[]) { int n, i; long long t, nn; scanf("%d %lld", &n, &t); nn = (((long long) 1) << n); for (i=0;i<nn;i++) scanf("%lld", &buf[i]); if (t%2==0) for (i=0;i<nn;i++) printf("%lld ", buf[i]); else for (i=nn-1;i>=0;i--) printf("%lld ", buf[i]); printf("\n"); return 0; } |