Sum of Query I
Submissions: 632   Accuracy:

37.37%

  Difficulty: Easy   Marks: 2

You need to calculate the following sum over Q queries.:

Assume array to be 1-indexed.

Input:
The first line of  input contains T, the number of test cases. T testcases follow. The first line of each testcase contains contains the size of array N. The second line of each test case contains the elements of array. The third  line of each test case contains q queries to be performed. The final line contains 2*q elements. The first element denoting L and the second element denoting R.

Output:
For each testcase, in a new line, print the required sum.

Constraints:
1 <= T <= 10
1 <= N <= 103
1 <= arr[i] <= 104
1 <= Q <= 103
1 <= L <= R <= N

Example:
Input:
1
7
2 3 4 5 1 6 7
4
1 7 2 4 2 6 3 7

Output:
714 64 230 304

** For More Input/Output Examples Use 'Expected Output' option **

Author: jain_rishabh


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.