// Przemysław Szpakowicz #include <algorithm> int main() { int logCardsAmount, shufflesAmount; scanf("%d%d", &logCardsAmount, &shufflesAmount); int cardsAmount = 1 << logCardsAmount; int numbersOnCards[cardsAmount]; for(int &numberOnCard : numbersOnCards) scanf("%d", &numberOnCard); if(shufflesAmount % 2) std::reverse(numbersOnCards, numbersOnCards + cardsAmount); for(int &numberOnCard : numbersOnCards) printf("%d ", numberOnCard); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | // Przemysław Szpakowicz #include <algorithm> int main() { int logCardsAmount, shufflesAmount; scanf("%d%d", &logCardsAmount, &shufflesAmount); int cardsAmount = 1 << logCardsAmount; int numbersOnCards[cardsAmount]; for(int &numberOnCard : numbersOnCards) scanf("%d", &numberOnCard); if(shufflesAmount % 2) std::reverse(numbersOnCards, numbersOnCards + cardsAmount); for(int &numberOnCard : numbersOnCards) printf("%d ", numberOnCard); } |