import java.util.*;


public class Solution {
    /**
     * 旋转数组
     * @param n int整型 数组长度
     * @param m int整型 右移距离
     * @param a int整型一维数组 给定数组
     * @return int整型一维数组
     */
  public int[] solve(int n, int m, int[] a) {
        // write code here
        //右移实际距离
        int l = m % n;
        if (l == 0) {
            return a;
        }

        rotate(a, 0, n - 1 - l);
        rotate(a, n - l, n - 1);
        rotate(a, 0, n - 1);

        return a;
    }

    /**
     * 1 2 3 4 5 6 右移 2位
     * 4 3 , 2 1 6 5
     * 5 6 1 2 ,  3 4
     * 0 --- n-2-1 , n-2 --- n-1
     */
    private void rotate(int[] a, int x, int y) {
        for (int i = x, j = y; i < j; i++, j--) {
            int temp = a[i];
            a[i] = a[j];
            a[j] = temp;
        }
    }
}