Hide

Problem O
Zoom

To determine whether your company is successful, your boss has to look at a long list of numbers! So many numbers, in fact, that they need some way to simplify the data. You came up with the idea to summarize the list by “zooming out”. How do you zoom out? Just discard everything except every $k^{th}$ number in the list, for some $k\ge 1$. Now, you just have to implement the idea, and your company will surely be very successful!

Input

The first line contains integers $n$ and $k$, with $1\le k\le n\le 10^5$. The second line contains $n$ integers $x_1,x_2,\dots ,x_ n$ describing the list of numbers. It is guaranteed that $0\le x_ i\le 2^{30}$ for $i=1,\dots ,n$.

Output

Display the sequence $x_{k},x_{2k},\dots ,x_{qk}$ where $q=\lfloor \frac nk\rfloor $.

Sample Input 1 Sample Output 1
10 2
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10
Sample Input 2 Sample Output 2
8 3
1 8 2 7 3 6 4 5
2 6
Sample Input 3 Sample Output 3
5 5
9 9 9 9 3
3

Please log in to submit a solution to this problem

Log in