Find the sum

0

0 votes
Problem

f(x) is series 1,2,-2,3,-3,3,4,-4,4,-4. Given two positions l and r, find the sum of all elements from l to r(l and r inclusive).

Input : First line of the input contains a single integer T denoting number of test cases. For each test case, two integers l and r are given.

Output: Print the answer in a single line.

Constraints

  • 1 <= T <= 10, 1 <= l,r <= 10^12
Sample Input
3
1 1
1 3
1 4
Sample Output
1
1
4
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Explanation : For the 3rd case, the series is 1,2,-2,3. Therefore the sum will be 4.

Editor Image

?