#P5534. Arithmetic Progression Sum

    ID: 18764 Type: Default 1000ms 256MiB

Arithmetic Progression Sum

Arithmetic Progression Sum

Given the first two terms of an arithmetic progression and the number of terms, compute the sum of the progression.

An arithmetic progression is defined as: for any sequence \(a_1, a_2, \ldots, a_n\) if for every \(i \in [1, n)\) we have \(a_{i+1} - a_i = d\) (where \(d\) is a constant), then it is called an arithmetic progression. The sum of the first \(n\) terms is given by the formula: \(S = \frac{n}{2}(2a_1 + (n-1)d)\).

inputFormat

Input contains three space-separated integers representing the first term (a_1), the second term (a_2), and the number of terms (n) respectively.

outputFormat

Output the sum of the arithmetic progression.

sample

1 2 3
6