atcoder#ARC123F. [ARC123F] Insert Addition
[ARC123F] Insert Addition
Score : points
Problem Statement
For a sequence of integers , let denote the sequence obtained by inserting between and for each . More formally:
- Let for each .
- Let be defined as a sequence of integers $f(P) = (P_1, Q_1, P_2, Q_2, \ldots, P_{M-1}, Q_{M-1}, P_M)$.
Given are three positive integers , , and where . Let us begin with a sequence and define a sequence as follows.
- Do the following times: replace with .
- Then, remove from all values greater than and let be the resulting sequence.
Find .
Constraints
- is at most the number of elements in the sequence .
Input
Input is given from Standard Input in the following format:
Output
Print a line containing , with a space in between.
1 1 4
1 7
1 4 3 2 3 4 1
Initially, . The replacements of with take place as follows.
- After the first replacement: .
- After the second replacement: .
- After the third replacement: .
- After the fourth replacement: $A = (1, 5, 4, 7, 3, 8, 5, 7, 2, 7, 5, 8, 3, 7, 4, 5, 1)$.
Thus, we have . We should report the -st through -th elements of this sequence.
1 1 4
2 5
4 3 2 3
Again, we have . We should report the -nd through -th elements of this sequence.
2 1 10
5 15
8 3 10 7 4 9 5 6 7 8 9
10 10 10
2 2
10