~/algor $ cat problems/massiv-k-ta-ongga-surish
Shift the array right by k
Medium
1000 ms
64 MB
49%
An array of $n$ elements and an integer $k$ are given. Cyclically shift the array to the right $k$ times: at each shift the last element moves to the beginning and the rest move one position to the right. Print the resulting array. $k$ may be very large.
Input
The first line contains two integers: $n$ and $k$.
The second line contains $n$ integers — the elements of the array.
Output
$n$ integers separated by spaces.
Note
$1 \le n \le 1000$
$0 \le k \le 10^{9}$
the elements are from $-10^{6}$ to $10^{6}$
Examples
Input #1
5 2 1 2 3 4 5
Output #1
4 5 1 2 3
Input #2
3 7 10 20 30
Output #2
30 10 20