#C11072. Digit Sum Sequence Generation

    ID: 40348 Type: Default 1000ms 256MiB

Digit Sum Sequence Generation

Digit Sum Sequence Generation

We define a sequence (a_1, a_2, \dots, a_L) by the following recurrence: [ a_1 = N, ] [ a_{i+1} = a_i + s(a_i), \quad \text{for } i \ge 1, ] where (s(a_i)) denotes the sum of the digits of (a_i). For a given initial number (N) and a length (L), compute the first (L) terms of the sequence.

For example, if (N=5) and (L=3), the sequence is: 5, 10, 11 since (5 + 5 = 10) and (10 + (1+0) = 11).

inputFormat

The first line contains a single integer (T), the number of test cases. Each of the following (T) lines contains two space-separated integers (N) and (L), representing the starting number and the length of the sequence, respectively.

outputFormat

For each test case, output a line beginning with the string "Case i:" (where (i) is the test case number starting from 1) followed by the (L) numbers of the generated sequence, separated by a single space.## sample

1
5 3
Case 1: 5 10 11

</p>