#C357. Rotate Array

    ID: 47011 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, after k rotations, each element of the array moves to a new position based on the formula:

new_index = (old_index + k) \mod n

where \( n \) is the number of elements in the array and \( k \) is the given number of steps. The input is provided through standard input and the rotated array should be printed to standard output with the numbers separated by a single space.

Note: It is guaranteed that the array contains at least one element and k is a non-negative integer.

inputFormat

The input is given in a single line via standard input containing several space-separated integers. The first integer is n which denotes the number of elements in the array. The second integer is k representing the number of steps to rotate the array. The next n integers represent the array elements.

For example: 7 3 1 2 3 4 5 6 7

outputFormat

Output the rotated array as a single line of space-separated integers via standard output.

For example, for the above input the correct output is: 5 6 7 1 2 3 4

## sample
7 3 1 2 3 4 5 6 7
5 6 7 1 2 3 4