Gldr and the difference

4.4

7 votes
Math, Number theory, Basic Math, Algorithms
Problem

Gldr gives you two numbers L and R and he wants the sum of the difference between every adjacent element between L and R.

Sum is calculated as follows : R1i=L(i+1)(i) 

For Example :  if L = 1 and R = 3, the sum =  (2-1) + (3-2)   , so sum = 2 .

Constrains :

1T100

 109L<R109  .

Input :

The first line contains one number T the number of test cases .

The second line contains two numbers L  and R .

Output :

Print one number the sum of the difference between every adjacent elements between L and R .

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For test case 1  , sum = 1 - 0 = 1 

For test case 2 , sum= 0 - (-1) =1

 

Editor Image

?