#K50112. Fibonacci Sequence Variations with a Skipped Element

    ID: 28793 Type: Default 1000ms 256MiB

Fibonacci Sequence Variations with a Skipped Element

Fibonacci Sequence Variations with a Skipped Element

You are given two initial integers \(a\) and \(b\), and an integer \(n\) (where \(n \geq 1\)). A Fibonacci-like sequence is defined as follows:

[ F_1 = a, \quad F_2 = b, \quad F_i = F_{i-1} + F_{i-2} \text{ for } i \geq 3 ]

The task is to determine the number of distinct variations of the sequence when exactly one element is skipped at the \(n\)th position. The skipping operation can be performed by removing either the \((n-1)\)th or the \((n-2)\)th element, which leads to two different outcomes when \(n \geq 3\). For the cases when \(n = 1\) or \(n = 2\), skipping is not defined and the result is \(0\).

Note: The answer is always 2 when \(n \geq 3\), and 0 when \(n \in \{1, 2\}\).

inputFormat

The input consists of three space-separated integers: \(a\), \(b\), and \(n\).

\(a\) and \(b\) represent the first two elements of the Fibonacci-like sequence, and \(n\) is the position at which a number is skipped.

outputFormat

Output a single integer representing the number of distinct variations of the sequence after skipping the \(n\)th position.

## sample
2 3 5
2