No.538 N.G.S.
Problem Statement
N.G.S. (Number Generator Syndrome) is a disease that affects people who have solved too many recurrence relations.
A person with this disease will, at the slightest trigger, keep saying numbers according to some recurrence relation.
This symptom is also known as sequence hiccups, and it can be stopped by saying the next number for them.
Your friend also has N.G.S. and is having sequence hiccups right now.
From the look on your friend's face, you have realized that the recurrence relation your friend is following has the form
.
Say the number your friend will say next before they do, and stop the sequence hiccups.
Input
$b_1 \ b_2 \ b_3$
The first line contains the last three numbers of the sequence your friend has said, separated by spaces.
All inputs are integers and satisfy the following constraints.
It is also guaranteed that the number your friend will say next is an integer.
Output
Output the number your friend will say next as an integer. Print a newline at the end.
Sample
Sample 1
Input
1 2 3
Output
4
In this case, $r = d = 1$, and the next number is 4.
Sample 2
Input
2 4 8
Output
16
In this case, $r=2, d = 0$, and the next number is 16.
Sample 3
Input
3 -2 8
Output
-12
The answer may be negative.
Sample 4
Input
21 9 3
Output
0
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
Tawara