#K4131. Generalized Fibonacci Sequence
Generalized Fibonacci Sequence
Generalized Fibonacci Sequence
You are given T test cases. For each test case, you are provided with three integers: n, a, and b. The values a and b are the first two terms of a generalized Fibonacci sequence. The sequence is defined as follows:
\( F_1 = a, \; F_2 = b, \; F_i = F_{i-1} + F_{i-2} \text{ for } i \ge 3 \)
Your task is to generate and print the first n terms of this sequence. Each term should be separated by a single space, and each test case's output should appear on a new line.
Example:
Input: 3 5 1 1 7 2 3 4 0 5</p>Output: 1 1 2 3 5 2 3 5 8 13 21 34 0 5 5 10
inputFormat
The first line of input contains an integer T, the number of test cases. Each of the following T lines contains three integers: n (the number of terms), a (the first term), and b (the second term) of the sequence. All values are separated by spaces.
T n a b n a b ... (T test cases)
outputFormat
For each test case, output a single line containing the first n terms of the generalized Fibonacci sequence. The terms must be separated by a single space.
## sample3
5 1 1
7 2 3
4 0 5
1 1 2 3 5
2 3 5 8 13 21 34
0 5 5 10
</p>