import java.io.BufferedReader;
import java.io.InputStreamReader;
public class tas {
public static void main(final String[] args) throws Exception {
try (final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
final String firstLine = br.readLine();
final String[] params = firstLine.split(" ");
final int n = Integer.parseInt(params[0]);
final int t = Integer.parseInt(params[1]);
final String secondLine = br.readLine().trim();
if (t % 2 == 1) {
final String[] cards = secondLine.split(" ");
for (int i = cards.length - 1; i > 0; i--) {
System.out.print(cards[i] + " ");
}
System.out.println(cards[0]);
} else {
System.out.println(secondLine);
}
}
}
}
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 | import java.io.BufferedReader; import java.io.InputStreamReader; public class tas { public static void main(final String[] args) throws Exception { try (final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) { final String firstLine = br.readLine(); final String[] params = firstLine.split(" "); final int n = Integer.parseInt(params[0]); final int t = Integer.parseInt(params[1]); final String secondLine = br.readLine().trim(); if (t % 2 == 1) { final String[] cards = secondLine.split(" "); for (int i = cards.length - 1; i > 0; i--) { System.out.print(cards[i] + " "); } System.out.println(cards[0]); } else { System.out.println(secondLine); } } } } |
English