#include <iostream> #include <cmath> using namespace std; unsigned long long int integer_pow(long long int x, long long int n) { unsigned long long int r = 1; while (n--) r *= x; return r; } int main() { int n, t, countA, i, x; //n = 1000000000; //cout << n; cin >> n; cin >> t; countA = integer_pow(2, n); if (t % 2 == 0) { for (i=0; i<countA; i++) { cin >> x; if (i > 0 ) { cout << " "; } cout << x; } cout << "\n"; return 0; } int a[countA]; for (i=0; i<countA; i++) { cin >> a[i]; } cout << a[countA-1]; for (i=countA-2; i>=0; i--) { cout << " " << a[i]; } cout << "\n"; 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 50 | #include <iostream> #include <cmath> using namespace std; unsigned long long int integer_pow(long long int x, long long int n) { unsigned long long int r = 1; while (n--) r *= x; return r; } int main() { int n, t, countA, i, x; //n = 1000000000; //cout << n; cin >> n; cin >> t; countA = integer_pow(2, n); if (t % 2 == 0) { for (i=0; i<countA; i++) { cin >> x; if (i > 0 ) { cout << " "; } cout << x; } cout << "\n"; return 0; } int a[countA]; for (i=0; i<countA; i++) { cin >> a[i]; } cout << a[countA-1]; for (i=countA-2; i>=0; i--) { cout << " " << a[i]; } cout << "\n"; return 0; } |