#C7828. Jump Sequence Sum

    ID: 51742 Type: Default 1000ms 256MiB

Jump Sequence Sum

Jump Sequence Sum

You are given an arithmetic sequence (also known as a jump sequence) defined by its first term A, common difference B, and the number of terms N. The sum of such a sequence can be calculated using the formula:

$$S = \frac{N}{2}\Bigl(2A + (N-1)B\Bigr)$$

Your task is to compute and output the sum of the jump sequence for each test case.

Input Format

The first line contains an integer T, the number of test cases. Each of the following T lines contains three integers A, B, and N separated by spaces.

Output Format

For each test case, output the sum of the jump sequence on a new line.

Note: Use the above formula where the sum is calculated as $$S = \frac{N}{2}(2A+(N-1)B)$$ in LaTeX format.

inputFormat

The input begins with an integer T representing the number of test cases. Each test case is in a separate line and consists of three space-separated integers: A (the first term), B (the common difference), and N (the number of terms).

Example:

2
3 2 5
-1 4 4

outputFormat

For each test case, print the computed sum of the jump sequence on a new line.

Example:

35
20
## sample
2
3 2 5
-1 4 4
35

20

</p>