P29003 [洛谷] Arithmetic Sequence
普及-
题目描述

Problem Description

Little X has given you the first two terms and the number of terms of an arithmetic sequence, and asks you to calculate the sum of all terms of this sequence.

Arithmetic Sequence: For a sequence \( a \) with \( n \) terms, if it satisfies that for any \( i \in [1, n) \), there is \( a_{i+1} - a_i = d \), where \( d \) is a constant, then this sequence is called an arithmetic sequence.

Input Format

A single line containing three integers \( a_1, a_2, n \), representing the first and second terms of the arithmetic sequence and the number of terms, respectively.

Data Range:

  • \( |a_1|, |a_2| \le 10^6 \).
  • \( 3 \le n \le 10^6 \).

Output Format

A single line containing one integer, representing the sum of all terms of the sequence.

Sample Input and Output

Sample Input #1

1 2 3

Sample Output #1

6

Sample Input #2

-5 -10 5

Sample Output #2

-75

Notes

Sample 1 Explanation:

The arithmetic sequence is 1 2 3, and the sum of its terms is \( 6 \).

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 2 3
样例输出
6