#include <cstdio> bool reversed; void foo(int n) { if(!n) return; int x; scanf("%d", &x); if(!reversed) printf("%d ", x); foo(n - 1); if(reversed) printf("%d ", x); } int main() { int n, t; scanf("%d%d", &n, &t); reversed = t & 1; foo(1 << n); printf("\n"); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <cstdio> bool reversed; void foo(int n) { if(!n) return; int x; scanf("%d", &x); if(!reversed) printf("%d ", x); foo(n - 1); if(reversed) printf("%d ", x); } int main() { int n, t; scanf("%d%d", &n, &t); reversed = t & 1; foo(1 << n); printf("\n"); } |