#C6292. Right Rotation of a List

    ID: 50036 Type: Default 1000ms 256MiB

Right Rotation of a List

Right Rotation of a List

Given a list of integers and an integer (k), rotate the list to the right by (k) steps. Formally, if the original list is (A = [a_0, a_1, \ldots, a_{n-1}]), then the rotated list (B) is defined as (B[i] = A[(i - k + n) \mod n]). Your task is to compute the rotated list.

inputFormat

The input consists of two lines. The first line contains space-separated integers representing the list (A). The second line contains a single integer (k), which is the number of positions to rotate (A) to the right.

outputFormat

Output the rotated list as a single line of space-separated integers.## sample

1 2 3 4 5
2
4 5 1 2 3