#K62737. Sequence Generator

    ID: 31598 Type: Default 1000ms 256MiB

Sequence Generator

Sequence Generator

Given two integers (N) and (K), you are required to generate a sequence of (N) numbers. The sequence is defined as follows: the first (K) elements are all (1), and every subsequent element is the sum of the previous (K) elements. In other words, for (i > K), the (i^{th}) element, (a_i), is given by: [ a_i = \sum_{j=i-K}^{i-1} a_j ] For example, if (N=5) and (K=2), the sequence is: 1, 1, 2, 3, 5.

This problem tests your ability to implement sequential dynamic programming with a sliding window summation.

inputFormat

The first line of the input contains a single integer (T) representing the number of test cases. Each of the next (T) lines contains two space-separated integers (N) and (K), where (N) is the length of the sequence to generate and (K) is the number of preceding elements to sum to form the next element in the sequence.

outputFormat

For each test case, output the generated sequence in a single line. The numbers in each sequence should be separated by a single space.## sample

3
5 2
7 3
6 2
1 1 2 3 5

1 1 1 3 5 9 17 1 1 2 3 5 8

</p>