#C2776. Rotate a List

    ID: 46129 Type: Default 1000ms 256MiB

Rotate a List

Rotate a List

You are given a list of integers and an integer \(k\). Your task is to rotate the list to the right by \(k\) steps. This means that each element in the list moves to the right by \(k\) positions, and the elements that go past the end of the list wrap around to the beginning.

For example, if you start with the list [1, 2, 3, 4, 5, 6, 7] and \(k = 3\), the rotated list will be [5, 6, 7, 1, 2, 3, 4].

inputFormat

The input consists of three lines:

  • The first line contains an integer \(n\), the number of elements in the list.
  • The second line contains \(n\) space-separated integers representing the list.
  • The third line contains an integer \(k\), the number of steps to rotate the list to the right.

outputFormat

Output the rotated list in one line as space-separated integers.

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

</p>