P5534 [XR-3] Arithmetic Progression.
Description
Xiao X gives you the first two terms and the number of terms of an arithmetic progression. Please find the sum of all terms of this arithmetic progression.
Arithmetic progression: For an $n$-term sequence $a$, if for any $i \in [1,n)$ it satisfies $a_{i+1} - a_i = d$, where $d$ is a constant, then this sequence is called an arithmetic progression.
Input Format
One line with $3$ integers $a_1, a_2, n$, representing the 1st and 2nd terms of the arithmetic progression and the number of terms.
**Constraints:**
- $|a_1|,|a_2| \le 10^6$.
- $3 \le n \le 10^6$.
Output Format
One line with one integer, representing the answer.
Explanation/Hint
**Sample $1$ Explanation**
This arithmetic progression is `1 2 3`, and the sum of its terms is $6$.
Translated by ChatGPT 5