#K76502. Rotate Array
Rotate Array
Rotate Array
You are given an array of integers and a list of queries. For each query, you must rotate the array to the right by the given number of positions and output the resulting array.
For example, given an array \(A = [a_1, a_2, \dots, a_n]\) and an integer \(k\), a right rotation by \(k\) positions produces a new array \(A'\) defined by:
\(A'[i] = A[((i - k - 1) \mod n) + 1]\) for \(1 \le i \le n\).
Note: Use \(k \mod n\) to get the effective number of rotations.
inputFormat
The input is given via STDIN. The first line contains two integers \(n\) and \(q\), representing the number of elements in the array and the number of queries respectively. The second line contains \(n\) integers representing the elements of the array. The third line contains \(q\) integers, each representing the number of positions to rotate the array to the right.
outputFormat
For each of the \(q\) queries, output the resulting rotated array on a separate line. Each rotated array's elements should be printed in order, separated by spaces.
## sample5 1
1 2 3 4 5
1
5 1 2 3 4
</p>