Fibonacci sequence
Medium
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
{F_k}^{∞}_{k=-∞} - infinite sequence of integers, which satisfies the Fibonacci F_k = F_{k-1} + F_{k-2} (for any integer k). Are also given i, F_i, j, F_j, n (i ≠ j). Find F_n. Example of sequence:
Input
In the first line are the numbers i, F_i, j, F_j, n.
-1000 ≤ i, j, n ≤ 1000, -2000000000 ≤ F_k ≤ 2000000000 (k = min(i, j, n) ... max(i, j, n)).
Output
Derive a single number F_n.
Examples
Input #1
Answer #1
Submissions 897
Acceptance rate 6%