#P8762. [蓝桥杯 2021 国 ABC] 123
[蓝桥杯 2021 国 ABC] 123
Problem Description
Xiao Lan found an interesting sequence. The first few terms are as follows:
Xiao Lan noticed that the first term of this sequence is the integer . The next terms are the integers from to . The next terms are the integers from to . The next terms are the integers from to , and so on.
Xiao Lan wants to know the sum of a consecutive segment in this sequence.
Input Format
The first line contains an integer , which indicates the number of queries.
The next lines each contain one query. In the -th line, there are two integers and , meaning the query asks for the sum from the -th number to the -th number in the sequence.
Output Format
Output lines. Each line contains one integer representing the answer to the corresponding query.
3
1 1
1 3
5 8
1
4
8
Hint
For of the testdata, , .
For of the testdata, , .
For of the testdata, , .
For of the testdata, , .
For of the testdata, , .
For of the testdata, , .
For all testdata, , .
Lanqiao Cup 2021 National Contest Group A Problem E (Group B Problem F, Group C Problem F).
Translated by ChatGPT 5