#P10416. [蓝桥杯 2023 国 A] XYZ

[蓝桥杯 2023 国 A] XYZ

Problem Description

Given an interval [L,R][L,R], find how many triples X,Y,ZX,Y,Z satisfy X+Y=ZX+Y=Z and LX,Y,ZRL\le X,Y,Z\le R.

Input Format

This problem contains multiple queries.

The first line contains an integer TT, the number of queries.

The next TT lines each contain two integers Li,RiL_i,R_i, separated by a space, representing one query.

Output Format

Output TT lines. Each line contains one integer, the number of triples X,Y,ZX,Y,Z that satisfy the conditions.

2
1 3
1 4
3
6

Hint

[Sample Explanation 1]

1+1=21+1=2
1+2=31+2=3
2+1=32+1=3
1+3=41+3=4
2+2=42+2=4
3+1=43+1=4

[Test Case Scale and Conventions]

For 30%30\% of the testdata, T1000T\le 1000 and Li,Ri100L_i,R_i\le 100.
For all testdata, 1T1000001\le T\le 100000 and 1LiRi1091\le L_i\le R_i\le 10^9.

Translated by ChatGPT 5