#C7312. Right Shift Array

    ID: 51170 Type: Default 1000ms 256MiB

Right Shift Array

Right Shift Array

You are given an array of n integers and a non-negative integer K. Your task is to shift the elements of the array to the right by K positions.

This operation can be described mathematically as follows: given an array \(a = [a_0, a_1, \dots, a_{n-1}]\) and an integer \(K\), the array after shifting becomes \(a'\) such that:

\[ a'_i = a_{(i - K) \mod n} \]

You need to modify the array in-place and then output the shifted array.

inputFormat

The first line of input contains two integers n and K, where n is the number of elements in the array and K is the number of positions to shift.

The second line contains n space-separated integers, representing the array elements.

outputFormat

Output the shifted array as a sequence of n space-separated integers on a single line.

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