You have decided to implement a program that shuffles N cards. Each of the N cards contains one integer from 1 to N, without duplicates. Initially, the card with integer i (1 ≤ i ≤ N) is the i-th card from the top. That is, the card with 1 is at the top, the card with 2 is second from the top, ..., the card with N is at the bottom, and so on. N) are placed at the bottom of the stack. This time, the cards are shuffled in the following way The stacked cards are divided into sets of M cards from the top. However, if the bottom set has less than M cards, it remains less than M. The cards are divided into sets of M cards from the top. The cards are rearranged so that the i-th set from the top (1 ≤ i ≤ M) is the i-th set from the bottom. That is, after separating them into their respective sets, the top set is the bottom, the second set from the top is the second from the bottom, ..., and so on. The second set from the top is the second from the bottom, ..., and the bottom set is the top. This operation is called a single shuffle. To shuffle again, repeat the same operation from the previous shuffled state. Output the order of the cards after shuffling K times. Input example 1 is shown below. Since N = 9, there are 9 cards. M = 3, so the cards are divided into sets of 3 cards each. Rearrange each set in the manner described above. This time, K = 1, so the shuffling is complete. Input values Input is given in the following format N M K The number of cards is given as an integer N, the number of cards per set as an integer M, and the number of shuffles as an integer K, in this order, separated by spaces. The input is on a single line, with a single newline at the end. Expected output Output the cards after shuffling K times in the following format, from top to bottom c_1 c_2 .... c_N The expected output consists of N lines. Each i-th line (1 ≤ i ≤ N) should contain c_i, the number of the i-th card from the top after shuffling. All output must be integers. The last line of output must end with a newline and must not contain any extra characters or blank lines.
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int K = sc.nextInt(); int[] cards = new int[N]; for (int i=0; i<N; i++) { cards[i] = i+1; } for (int i= 0; i<K; i++) { int[] cards2 = new int[N]; int[] temp = new int[M]; int index = 0; int cardIndex = 0; for (int j=0; j<N; j++) { if (j%M == 0) { for (int k=0; k<M; k++) { temp[k] = cards[cardIndex]; cardIndex++; } } if (j%M == 0) { for (int