Carl Friedrich Gauss was a great mathematician. When he was a child, his teacher told him to sum up all the numbers from 1 to 100 to keep him busy for some time. To his surprise, Gauss solved the problem in a few moments. He contributed in many fields of science. Some of his contributions are used in Computer Science too! #Respect!
In this problem, we want to keep you busy too! You have to find the sum of an arithmetic sequence. In mathematics, an arithmetic sequence is a sequence of numbers such that the difference between two consecutive terms is constant.
But in this problem, we are only interested in increasing arithmetic sequence where each term is greater than the previous term. You will be given the first two terms and the last term of an increasing arithmetic sequence. You have to find the sum of all the terms of the given sequence.
The first line of the input will only contain a single integer denoting the number of test cases. In the next lines, there will be 3 integers where is the first term, is the second term and is the last term of the sequence. It is guaranteed that a valid sequence of integers can be formed from the given 3 integers.
For each test case, print the sum of the sequence in a single line.
4 1 2 6 -6 -5 -1 2 7 22 -8 -3 17
21 -21 60 27
Login to submit