#include <cstdio> #include <cstdint> #include <cstdlib> int main() { uint32_t n, t; scanf("%d %d\n", &n, &t); uint32_t number_of_cards = 1 << n; uint32_t* cards = (uint32_t*) malloc(sizeof(uint32_t) *number_of_cards); for (int i = 0; i < number_of_cards; ++i){ scanf("%d", cards + i); } if (t % 2 == 0){ number_of_cards--; for (int i = 0; i < number_of_cards; ++i){ printf("%d ", cards[i]); } printf("%d\n", cards[number_of_cards]); } else { for (int i = number_of_cards - 1; i > 0; --i){ printf("%d ", cards[i]); } printf("%d\n", cards[0]); } 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 <cstdio> #include <cstdint> #include <cstdlib> int main() { uint32_t n, t; scanf("%d %d\n", &n, &t); uint32_t number_of_cards = 1 << n; uint32_t* cards = (uint32_t*) malloc(sizeof(uint32_t) *number_of_cards); for (int i = 0; i < number_of_cards; ++i){ scanf("%d", cards + i); } if (t % 2 == 0){ number_of_cards--; for (int i = 0; i < number_of_cards; ++i){ printf("%d ", cards[i]); } printf("%d\n", cards[number_of_cards]); } else { for (int i = number_of_cards - 1; i > 0; --i){ printf("%d ", cards[i]); } printf("%d\n", cards[0]); } return 0; } |