#C1861. Cyclic Array Rotation
Cyclic Array Rotation
Cyclic Array Rotation
You are given an array of n integers and an integer m. Your task is to perform a cyclic rotation of the array in a clockwise direction by m positions. A rotation means that each element of the array is shifted to the right by m places and the elements that fall off are re-introduced at the beginning of the array.
The rotation operation can be formally described as follows. Given an array \(A = [a_0, a_1, \dots, a_{n-1}]\) and an integer \(m\), after rotation the new array is:
[ A' = [a_{(n-m) \bmod n}, a_{(n-m+1) \bmod n}, \dots, a_{(n-1) \bmod n}, a_{0}, a_{1}, \dots, a_{(n-m-1) \bmod n}] ]
Note that if \(m \ge n\), then \(m\) is first reduced modulo \(n\) before the rotation is applied.
Your program should read the input from standard input (stdin) and write the result to standard output (stdout).
inputFormat
The first line contains two space-separated integers: n (the number of elements in the array) and m (the number of positions to rotate).
The second line contains n space-separated integers representing the array elements.
outputFormat
Output the rotated array as a sequence of space-separated integers in a single line.
## sample5 2
1 2 3 4 5
4 5 1 2 3
</p>