#C9802. Rotate Array

    ID: 53936 Type: Default 1000ms 256MiB

Rotate Array

Rotate Array

You are given an array of n integers and a non-negative integer k. Your task is to rotate the array to the right by k steps. In other words, each element is shifted to the right by k positions, and the elements that overflow from the end wrap around to the beginning of the array.

The rotation can be formally defined by the formula:

$$\text{rotated}[((i+k) \mod n)] = \text{arr}[i] \quad \text{for } 0 \leq i < n.$$

Implement a program to perform this rotation and output the rotated array.

inputFormat

The first line contains two space-separated integers n and k, where n is the number of elements in the array and k is the number of right-rotation steps. The second line contains n space-separated integers representing the array.

outputFormat

Output the rotated array as a single line of space-separated integers.## sample

7 3
1 2 3 4 5 6 7
5 6 7 1 2 3 4

</p>