#K85837. Arithmetic Sequence Summation

    ID: 36730 Type: Default 1000ms 256MiB

Arithmetic Sequence Summation

Arithmetic Sequence Summation

In this problem, you are given an arithmetic sequence that starts with an integer X and each successive term increases by 2. Your task is to compute the sum of the first N terms of this sequence.

The sequence is defined as follows:

\[ a_0 = X, \quad a_i = a_{i-1} + 2 \quad \text{for } i \geq 1 \]

The sum for the first N terms can be derived using the formula:

\[ S = N \times (X + N - 1) \]

For example, if N = 5 and X = 1, then:

\[ S = 5 \times (1 + 5 - 1) = 5 \times 5 = 25 \]

Solve this problem for multiple test cases provided in the input.

inputFormat

The first line contains an integer T, representing the number of test cases. Each of the following T lines contains two space-separated integers N and X where:

  • N is the number of terms in the sequence.
  • X is the starting number of the sequence.

outputFormat

For each test case, output a single line with the sum of the first N terms of the sequence.

## sample
3
5 1
3 10
4 7
25

36 40

</p>