import java.util.*;
class tas {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
List<Integer> list = new ArrayList<Integer>();
int n = scanner.nextInt();
int t = scanner.nextInt();
n = (int) Math.pow(2, n);
int liczba = 0;
for (int i = 0; i < n; i++) {
liczba = scanner.nextInt();
list.add(liczba);
}
if (t % 2 != 0)
Collections.reverse(list);
for (Integer e : list)
System.out.print(e + " ");
scanner.close();
}
}
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 | import java.util.*; class tas { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); List<Integer> list = new ArrayList<Integer>(); int n = scanner.nextInt(); int t = scanner.nextInt(); n = (int) Math.pow(2, n); int liczba = 0; for (int i = 0; i < n; i++) { liczba = scanner.nextInt(); list.add(liczba); } if (t % 2 != 0) Collections.reverse(list); for (Integer e : list) System.out.print(e + " "); scanner.close(); } } |
English