#C4624. Arithmetic Progression Properties
Arithmetic Progression Properties
Arithmetic Progression Properties
Given an arithmetic progression defined by its first term A, common difference D, and number of terms N, your task is to compute the Nth term and the sum of the first N terms.
The Nth term is given by the formula: \( a_N = A + (N-1) \times D \).
The sum of the first N terms is given by: \( S_N = \frac{N}{2} \times (2A + (N-1) \times D) \).
Read the input from the standard input (stdin) and write the output to the standard output (stdout).
inputFormat
The input consists of multiple lines. The first line contains an integer T, representing the number of test cases. Each of the following T lines contains three space-separated integers: A, D, and N, where A is the first term, D is the common difference, and N is the number of terms in the arithmetic progression.
For example:
1 1 1 5
outputFormat
For each test case, output two space-separated integers on a new line: the Nth term of the arithmetic progression and the sum of the first N terms.
For example, the output for the above input should be:
5 15## sample
1
1 1 5
5 15
</p>