SP10611 RRANGE - Ranges

Description

There are N contiguous cells numbered from 1 to N. Initially, each cell contains a 0 in it. A sub-contiguous group of cells can be updated this way: 1\) A range \[i,j\] is defined such that i < j 2\) The cell numbered i is added 1; the cell numbered i + 1 is added 2, and so on until the cell numbered j is reached and added j – i + 1 For example, if N = 7 and the updates \[3, 6\] and \[4,7\] were performed, this is what would happen. Initially: {0,0,0,0,0,0,0} Update \[3,6\]: {0,0,1,2,3,4,0} Update \[4,7\]: {0,0,1,3,5,7,4} After performing some update operations, it would be amazing to answer questions like the following: 1\) A range \[u,v\] is defined such that u < v 2\) The answer is the sum of every cell in the range \[u,v\] (both u and v are included) modulus 10,000 Given N and U updates ranges. You have to write a program capable of answering Q questions.

Input Format

The first line contains three integers: N (1

Output Format

For each question \[u,v\] you must print the sum of all contiguous cells starting at u and ending at v modulus 10,000.