#C3225. Rotate Array
Rotate Array
Rotate Array
Given an array of integers and a non-negative integer k, rotate the array to the right by k steps. That is, move the last k elements of the array to the front, preserving their order.
More formally, let \( n \) be the length of the array and \( k' = k \bmod n \) (when \( n > 0 \)). Then, the rotated array is formed by \( arr[n-k':n] \) concatenated with \( arr[0:n-k'] \).
If the array is empty, simply output an empty array.
inputFormat
The input is given via standard input (stdin) in the following format:
- The first line contains a single integer \( n \) representing the number of elements in the array.
- The second line contains \( n \) space-separated integers denoting the array elements. If \( n=0 \), this line may be empty.
- The third line contains a single integer \( k \), the number of positions to rotate the array.
outputFormat
Output the rotated array to standard output (stdout) in a single line. The elements should be space-separated. If the array is empty, output nothing.
## sample5
1 2 3 4 5
2
4 5 1 2 3