#C3085. Sequence Generation and Iterative Modification
Sequence Generation and Iterative Modification
Sequence Generation and Iterative Modification
You are given two integers n and m. Your task is to first generate a sequence of n integers where:
- The first element is 1.
- Each subsequent element is twice the previous one, i.e. \( a_i = 2 \times a_{i-1} \) for \( i \ge 2 \).
Then, perform exactly m iterations. In each iteration, for every odd-positioned element (positions 1, 3, 5, ... in 1-based indexing), if there exists a next element, add the value of the next element to it.
For example:
- For \( n=5 \) and \( m=0 \), the sequence is:
1 2 4 8 16
. - For \( n=5 \) and \( m=1 \), the updated sequence is:
3 2 12 8 16
(first element becomes \(1+2=3\) and third element becomes \(4+8=12\)). - For \( n=5 \) and \( m=2 \), the sequence becomes:
5 2 20 8 16
.
Output the final sequence as space-separated integers.
inputFormat
The input consists of a single line containing two integers n and m, separated by a space.
\( 1 \leq n \leq 10^3 \) and \( m \geq 0 \).
outputFormat
Output the final sequence after performing the iterative modifications. The sequence should be printed as space-separated integers on one line.
## sample5 0
1 2 4 8 16