#include <math.h> #include <stdio.h> #include <stdlib.h> int main() { long n, t; scanf("%ld %ld", &n, &t); long count = pow(2, n); bool reverse = t % 2; if (reverse) { long *tab = (long*)malloc(count * sizeof(long)); for (long i = 0; i < count; i++) { scanf("%ld", &tab[i]); } for (long i = count - 1; i >= 0; i--) printf("%ld ", tab[i]); } else { long val; for (long i = 0; i < count; i++) { scanf("%ld", &val); printf("%ld ", val); } } 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 | #include <math.h> #include <stdio.h> #include <stdlib.h> int main() { long n, t; scanf("%ld %ld", &n, &t); long count = pow(2, n); bool reverse = t % 2; if (reverse) { long *tab = (long*)malloc(count * sizeof(long)); for (long i = 0; i < count; i++) { scanf("%ld", &tab[i]); } for (long i = count - 1; i >= 0; i--) printf("%ld ", tab[i]); } else { long val; for (long i = 0; i < count; i++) { scanf("%ld", &val); printf("%ld ", val); } } return 0; } |