No.1379 Postponed
Problem Statement
You are given a sequence of positive integers $A^{(0)} = (A^{(0)}_1, A^{(0)}_2, \ldots, A^{(0)}_N)$ of length $N$.
The sequence $A^{(0)}$ is sorted in ascending order.
That is, for every integer $i$ satisfying $1 \leq i \leq N-1$, $A^{(0)}_i \leq A^{(0)}_{i+1}$ holds.
For $t = 1, 2, 3, \ldots$, the sequence $A^{(t)} = (A^{(t)}_1, A^{(t)}_2, \ldots, A^{(t)}_N)$ is defined recursively as follows.
$\begin{equation}
A^{(t)}_i := \begin{cases} A^{(t-1)}_{i+1} & (\text{if}\,\, i < A^{(t-1)}_1 + 1)\\
A^{(t-1)}_1 & (\text{if}\,\, i = A^{(t-1)}_1 + 1)\\
A^{(t-1)}_{i} & (\text{if}\,\, i > A^{(t-1)}_1 + 1)\\
\end{cases}\end{equation} \,\,\,\,\,\, (\text{for}\,\, i = 1, 2, \ldots, N)$
That is, the sequence $A^{(t)}$ is obtained from the sequence $A^{(t-1)}$ by cyclically shifting its first $A^{(t-1)}_1+1$ elements to the left $1$ time.
Given a non-negative integer $K$, find the sequence $A^{(K)}$.
Input
$N\ K$
$A^{(0)}_1\ A^{(0)}_2\ \cdots\ A^{(0)}_N$
$2 \leq N \leq 100$
$0 \leq K \leq 10^{18}$
$1 \leq A^{(0)}_i \leq N-1$
$A^{(0)}_i \leq A^{(0)}_{i+1}$
All inputs are integers.
Output
$A^{(K)}_1\ A^{(K)}_2\ \cdots\ A^{(K)}_N$
Print the elements of $A^{(K)}$ in the order $A^{(K)}_1, A^{(K)}_2, \ldots, A^{(K)}_N$ on one line, separated by spaces.
Print a newline at the end.
Sample
Sample 1
Input
5 3 2 3 3 4 4
Output
2 4 3 3 4
$A^{(0)} = (2, 3, 3, 4, 4)$
$A^{(1)} = (3, 3, 2, 4, 4)$
$A^{(2)} = (3, 2, 4, 3, 4)$
$A^{(3)} = (2, 4, 3, 3, 4)$
as shown above.
Sample 2
Input
10 1000 1 3 4 5 5 6 8 8 9 9
Output
1 4 3 5 5 6 8 9 8 9
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
leaf_1415
37zigen