#include<bits/stdc++.h> #include<cstdio> using namespace std; #define R(p, k) for(int i = p; i <= k; i++) #define RI(i, p, k) for(int i = p; i <= k; i++) #define IR(k, p) for(int i = k; i >= p; i--) #define IRI(i, p, k) for(int i = k; i >= p; i--) #define DEB 0 #if DEB #define EPRLL(a) fprintf(stderr, "%s %lld ", #a, a); #define EPRN fprintf(stderr, "\n"); #else #define EPRLL(a) #define EPRN #endif const int MN=(1<<20)+5; int n, t, dane[MN]; int main(){ scanf("%d%d", &n, &t); n=1<<n; R(0, n-1) scanf("%d", &dane[i]); if(t%2==0) R(0, n-1) printf("%d ", dane[i]); else IR(n-1, 0) printf("%d ", dane[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 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #include<bits/stdc++.h> #include<cstdio> using namespace std; #define R(p, k) for(int i = p; i <= k; i++) #define RI(i, p, k) for(int i = p; i <= k; i++) #define IR(k, p) for(int i = k; i >= p; i--) #define IRI(i, p, k) for(int i = k; i >= p; i--) #define DEB 0 #if DEB #define EPRLL(a) fprintf(stderr, "%s %lld ", #a, a); #define EPRN fprintf(stderr, "\n"); #else #define EPRLL(a) #define EPRN #endif const int MN=(1<<20)+5; int n, t, dane[MN]; int main(){ scanf("%d%d", &n, &t); n=1<<n; R(0, n-1) scanf("%d", &dane[i]); if(t%2==0) R(0, n-1) printf("%d ", dane[i]); else IR(n-1, 0) printf("%d ", dane[i]); printf("\n"); return 0; } |