#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int tab[1048580];
long long pot(int a, int n)
{
if(n==0)
return 1;
if(n%2 == 1)
return a * pot(a, n - 1);
long long w = pot(a, n/2);
return w * w;
}
int main(){
int x, t;
scanf("%d%d", &x, &t);
x=pot(2,x);
//printf("%d", x);
for (int i=0; i<x; i++) scanf("%d", &tab[i]);
if(t%2==1){
for (int i=0; i<x; i++) printf("%d ", tab[x-i-1]);
}
else for (int i=0; i<x; i++) printf("%d ", tab[i]);
}
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 | #include <cstdio> #include <algorithm> #include <cmath> using namespace std; int tab[1048580]; long long pot(int a, int n) { if(n==0) return 1; if(n%2 == 1) return a * pot(a, n - 1); long long w = pot(a, n/2); return w * w; } int main(){ int x, t; scanf("%d%d", &x, &t); x=pot(2,x); //printf("%d", x); for (int i=0; i<x; i++) scanf("%d", &tab[i]); if(t%2==1){ for (int i=0; i<x; i++) printf("%d ", tab[x-i-1]); } else for (int i=0; i<x; i++) printf("%d ", tab[i]); } |
English