Recursion - 3#11250

Recursion - 3

1 segundo
128 megabytes
Muy fácil

The numbers a, b, c are given. Implement the recursive function:

f(n) = \begin{cases} 0, & n < 0 \\ a, & n = 0 \\ f(n - 1) + b \cdot f(n - 2) + c, & n > 0 \end{cases}

Entrada

Four nonnegative integers: a, b, c~(a, b, c \le 1000) and n~(0 \le n \le 1000).

Salida

Print the value of modulo 10^9 + 7.

Ejemplos

Ejemplo 1

Loading
Loading