#include <iostream>
#include <vector>
int pow2(int exp) {
int r=1,b=2;
while(exp) {
if (exp & 1) {
r *= b;
}
exp >>= 1;
b *= b;
}
return r;
}
int main() {
int n, t;
std::cin >> n >> t;
int c = pow2(n);
if (t&1) {
std::vector<int> v(c);
while(c--) {
std::cin >> v[c];
}
for(auto it=v.begin(); it!=v.end(); it++) {
std::cout << *it;
if(it+1 != v.end()) {
std::cout << ' ';
}
}
} else {
int x;
while(c--) {
std::cin >> x;
std::cout << x;
if (c) {
std::cout << ' ';
}
}
}
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #include <iostream> #include <vector> int pow2(int exp) { int r=1,b=2; while(exp) { if (exp & 1) { r *= b; } exp >>= 1; b *= b; } return r; } int main() { int n, t; std::cin >> n >> t; int c = pow2(n); if (t&1) { std::vector<int> v(c); while(c--) { std::cin >> v[c]; } for(auto it=v.begin(); it!=v.end(); it++) { std::cout << *it; if(it+1 != v.end()) { std::cout << ' '; } } } else { int x; while(c--) { std::cin >> x; std::cout << x; if (c) { std::cout << ' '; } } } return 0; } |
English