#P5534. 【XR-3】等差数列

【XR-3】等差数列

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 nn-term sequence aa, if for any i[1,n)i \in [1,n) it satisfies ai+1ai=da_{i+1} - a_i = d, where dd is a constant, then this sequence is called an arithmetic progression.

Input Format

One line with 33 integers a1,a2,na_1, a_2, n, representing the 1st and 2nd terms of the arithmetic progression and the number of terms.

Constraints:

  • a1,a2106|a_1|,|a_2| \le 10^6.
  • 3n1063 \le n \le 10^6.

Output Format

One line with one integer, representing the answer.

1 2 3

6

-5 -10 5

-75

Hint

Sample 11 Explanation

This arithmetic progression is 1 2 3, and the sum of its terms is 66.

Translated by ChatGPT 5