Sum Sum Sumzy

0

0 votes
Grammar-Verified, Grammar-Verified, Easy
Problem

You are given a sequence whose first five terms are 3, 0, 1, 6, and 7. You have to process Q queries containing the following:

  • An integer L
  • An integer R which is greater than or equal to L

Write a program to find the sum of all the elements from the \(L^{th}\) position to the \(R^{th}\) position in the sequence.

Input format

  • First line: Q
  • Next Q lines: Two space-separated integers L and R

Output format

For each query, print the sum of all elements from the \(L^{th}\) position to the \(R^{th}\) position in the sequence.

Constraints

\(1 ≤ Q ≤ 10^5\)
\(1 ≤ L ≤ R ≤ 10^5\)

Sample Input
5
1 3
2 3
4 4
3 4
2 5
Sample Output
4
1
6
7
14
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For first query the answer is 4 as the first three terms are 3,0,1.
For third query the answer is 6 as 4th term is 6.

Contributers:
Editor Image

?