#K1. Right Rotation of Array

    ID: 23147 Type: Default 1000ms 256MiB

Right Rotation of Array

Right Rotation of Array

You are given a sequence of n integers and a non-negative integer k. Your task is to rotate the array to the right by k positions.

If k is greater than or equal to n, only the effective rotations, i.e., k mod n, should be performed.

The rotated array \(A'\) is defined as:

\(A'_i = A_{(i - k) \mod n}\) for \(0 \leq i < n\).

For example, if the array is [1, 2, 3, 4, 5] and k = 3 then the rotated array is [3, 4, 5, 1, 2].

inputFormat

The input is given from standard input (stdin) in a single line. The first integer is n (the number of elements in the array), followed by k (the number of right rotations), and then n space-separated integers representing the array elements.

outputFormat

Print the rotated array as a sequence of space-separated integers on a single line to standard output (stdout).## sample

5 3
1 2 3 4 5
3 4 5 1 2