eolymp
bolt
Try our new interface for solving problems
Problems

Arithmetic progressions

Arithmetic progressions

Let $a_n, b_n, c_n$ be arithmetic progressions. It is known that \begin{itemize} \item $a_1 + b_1 + c_1 = p$, \item $a_2 + b_2 + c_2 = q$ \end{itemize} For the given positive integer $k$ find the value of $a_k + b_k + c_k$. \InputFile Three integers $p, q~(|p|, |q| \le 10^{18}), k~(k > 0)$. \OutputFile Print the value of $a_k + b_k + c_k$. It is known that output is no more than $10^{18}$ by absolute value.
Time limit 1 second
Memory limit 128 MiB
Input example #1
2 5 10
Output example #1
29
Source 2014 OMO Fall