#C7379. Modified Fibonacci Even Sum

    ID: 51243 Type: Default 1000ms 256MiB

Modified Fibonacci Even Sum

Modified Fibonacci Even Sum

This problem involves a modification of the traditional Fibonacci sequence. Given two starting integers a and b, the sequence is generated by summing the two previous terms. You are required to compute the sum of the even-valued terms in the first n terms of this sequence.

The sequence is defined as follows: \(F_1 = a,\) \(F_2 = b,\) and for \(i \ge 3,\) \(F_i = F_{i-1} + F_{i-2}.\) The task is to calculate:

\[ S = \sum_{i=1}^{n} \mathbb{1}_{\{F_i\,\text{is even}\}} \cdot F_i \]

where \(\mathbb{1}\) is the indicator function that returns 1 when its condition is true, and 0 otherwise.

Make sure to handle input/output through standard input and output (stdin and stdout).

inputFormat

The input consists of a single line containing three space-separated integers: a, b, and n. Here, a and b are the first two terms of the modified Fibonacci sequence and n (n ≥ 1) is the number of terms to consider.

outputFormat

Output a single integer on a new line representing the sum of the even numbers among the first n terms of the modified Fibonacci sequence.## sample

2 3 10
188