#t219. 等差数列的第 k 项

等差数列的第 k 项

The k-th Term of an Arithmetic Progression

Problem Description

An arithmetic progression is a sequence in which, starting from the second term, the difference between each term and the previous one equals the same constant. This constant is called the common difference (usually denoted dd), and the first term is called the first term (usually denoted xx).

For example: an arithmetic progression with first term 55 and common difference 22 is: 5,7,9,11,13,…5, 7, 9, 11, 13, \dots. Its 1st term is 55, its 2nd term is 77, its 3rd term is 99, and so on.

Now given the first term xx and the common difference dd of an arithmetic progression, find the value of its kk-th term.

Input Format

One line containing three integers x,d,kx, d, k, separated by spaces. 0<x,d,k<10000 < x, d, k < 1000.

Output Format

Output one integer: the value of the kk-th term of the arithmetic progression.

Sample Input

5 1 3

Sample Output

7

Sample Explanation

First term x=5x = 5, common difference d=1d = 1, the sequence is: 5,6,7,…5, 6, 7, \dots. The 3rd term is 5+(3−1)×1=75 + (3-1) \times 1 = 7.

Hint

  • Three numbers on one line. The kk-th term = first term + (number of steps taken) × common difference — from the 1st term to the kk-th term, how many steps are taken?
  • Check against the sample: 5 1 3 → 7.