Gldr and the difference
Practice
4.4 (7 votes)
Math
Number theory
Basic math
Algorithms
Problem
82% Success 528 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
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 : \(\sum_{i=L}^{R-1} (i+1) - (i)\)
For Example : if \(L\) = 1 and \(R\) = 3, the sum = (2-1) + (3-2) , so sum = 2 .
Constrains :
\(1 \leq T \leq 100\)
\(-10^9 \leq L < R \leq 10^9\) .
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\) .
Submissions
Please login to view your submissions
Similar Problems
Points:20
1 votes
Points:20
15 votes
Tags:
Ad-HocMathematicsOpenApprovedEasyMathamatics
Points:20
1 votes
Tags:
AEasyMath
Editorial