#K43562. Modified Fibonacci Sequence Generator
Modified Fibonacci Sequence Generator
Modified Fibonacci Sequence Generator
In this problem, you are required to generate the first n terms of a modified Fibonacci sequence. The sequence is defined as follows:
- The first term is (a_0 = 0).
- The second term is (a_1 = 1).
- The third term is (a_2 = 1).
- For every term (i \geq 3), the recurrence relation is given by
[ a_i = a_{i-1} + a_{i-2} + a_{i-3} ]
Your program should read an integer n from standard input and output the first n terms of this sequence separated by spaces. Make sure your solution can handle the test cases provided.
inputFormat
The input consists of a single integer n (1 (\leq) n (\leq) a reasonable limit), representing the number of terms of the modified Fibonacci sequence to generate. The input is provided via standard input.
outputFormat
Print the first n terms of the modified Fibonacci sequence in one line, separated by a single space. The output is written to standard output.## sample
6
0 1 1 2 4 7