#K47017. Hybrid Sequence Generation
Hybrid Sequence Generation
Hybrid Sequence Generation
Given two initial integers a and b, generate a sequence of n terms defined as follows:
Let the sequence be \(s_0, s_1, s_2, \dots, s_{n-1}\) with \(s_0 = a\) and \(s_1 = b\). For every index \(i \ge 2\), the term \(s_i\) is determined by:
- If \(i\) is even, then \(s_i = s_{i-2} + s_{i-1}\). That is, \(s_i = s_{i-2} + s_{i-1}\).
- If \(i\) is odd, then \(s_i = s_{i-2} \times s_{i-1}\). That is, \(s_i = s_{i-2} \times s_{i-1}\).
Your task is to generate the first n terms of this hybrid sequence and output them as space-separated values on one line.
Examples:
Input: 2 3 5 Output: 2 3 5 15 20</p>Input: 1 1 8 Output: 1 1 2 2 4 8 12 96
inputFormat
The input consists of a single line containing three space-separated integers a, b, and n:
- a - the first term of the sequence.
- b - the second term of the sequence.
- n - the number of terms to generate.
Constraints: All values are positive integers.
outputFormat
Output a single line containing n space-separated integers, which are the first n terms of the hybrid sequence.
## sample2 3 5
2 3 5 15 20