#C4153. Rotate Array Right

    ID: 47660 Type: Default 1000ms 256MiB

Rotate Array Right

Rotate Array Right

You are given an array of integers and an integer number of steps. The task is to rotate the array to the right by the specified number of steps.

If the array has n elements, then the effective number of rotations is computed using the formula: \( k_{\text{eff}} = k \mod n \). For example, rotating \([1,2,3,4,5]\) by 2 steps results in \([4,5,1,2,3]\).

Note that an empty array remains unchanged regardless of the number of rotations.

inputFormat

The input is read from stdin and consists of three parts:

  1. An integer n denoting the number of elements in the array.
  2. A line containing n integers separated by spaces, representing the array elements. (If n is 0, this line may be empty.)
  3. An integer k representing the number of steps to rotate the array.

outputFormat

Output to stdout a single line containing the elements of the rotated array, separated by a single space. If the resulting array is empty, output an empty line.

## sample
5
1 2 3 4 5
0
1 2 3 4 5