#include <iostream> using namespace std; int tab[2000000]; int main() { ios_base::sync_with_stdio(0); int p,t,n=1; cin>>p>>t; for(int i=1;i<=p;i++)n=n<<1; for(int i=1;i<=n;i++)cin>>tab[i]; if(t%2==0)for(int i=1;i<=n;i++)cout<<tab[i]<<" "; if(t%2==1)for(int i=n;i>=1;i--)cout<<tab[i]<<" "; }
1 2 3 4 5 6 7 8 9 10 11 12 13 | #include <iostream> using namespace std; int tab[2000000]; int main() { ios_base::sync_with_stdio(0); int p,t,n=1; cin>>p>>t; for(int i=1;i<=p;i++)n=n<<1; for(int i=1;i<=n;i++)cin>>tab[i]; if(t%2==0)for(int i=1;i<=n;i++)cout<<tab[i]<<" "; if(t%2==1)for(int i=n;i>=1;i--)cout<<tab[i]<<" "; } |