#include <cstdio> #include <vector> using namespace std; vector<int> tab; int n, a, b; int main() { scanf("%d%d", &n, &a); n = 1<<n; if ((a % 2) == 0){ while(n--){ scanf("%d", &b); printf("%d ", b); } printf("\n"); } else { while(n--) { scanf("%d", &b); tab.push_back(b); } while (tab.size() > 0) { printf("%d ", tab.back()); tab.pop_back(); } printf("\n"); } }
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 | #include <cstdio> #include <vector> using namespace std; vector<int> tab; int n, a, b; int main() { scanf("%d%d", &n, &a); n = 1<<n; if ((a % 2) == 0){ while(n--){ scanf("%d", &b); printf("%d ", b); } printf("\n"); } else { while(n--) { scanf("%d", &b); tab.push_back(b); } while (tab.size() > 0) { printf("%d ", tab.back()); tab.pop_back(); } printf("\n"); } } |