#C8968. Tribonacci Sequence Generation

    ID: 53008 Type: Default 1000ms 256MiB

Tribonacci Sequence Generation

Tribonacci Sequence Generation

The Tribonacci sequence is a variation of the Fibonacci sequence where each term is the sum of the previous three terms. Given four integers \( n, a, b, c \), your task is to generate the first \( n \) elements of the Tribonacci sequence. The sequence starts with \( a \), \( b \), and \( c \), and then each subsequent element is computed as:

\( T_i = T_{i-1} + T_{i-2} + T_{i-3} \) for \( i \ge 3 \).

For example, if \( n = 5 \) and the starting values are \( 1, 1, 1 \), the sequence is: [1, 1, 1, 3, 5].

inputFormat

The input consists of a single line containing four space-separated integers:

  • \( n \): the number of elements in the sequence (\( n \ge 0 \)).
  • \( a, b, c \): the first three elements of the sequence.

If \( n = 0 \), no output should be produced.

outputFormat

Output the first \( n \) elements of the Tribonacci sequence in one line, separated by a single space. There should be no extra spaces at the end of the line.

## sample
5 1 1 1
1 1 1 3 5