P10416 [Lanqiao Cup 2023 National A] XYZ

Description

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

Input Format

This problem contains multiple queries. The first line contains an integer $T$, the number of queries. The next $T$ lines each contain two integers $L_i,R_i$, separated by a space, representing one query.

Output Format

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

Explanation/Hint

**[Sample Explanation 1]** $1+1=2$ $1+2=3$ $2+1=3$ $1+3=4$ $2+2=4$ $3+1=4$ **[Test Case Scale and Conventions]** For $30\%$ of the testdata, $T\le 1000$ and $L_i,R_i\le 100$. For all testdata, $1\le T\le 100000$ and $1\le L_i\le R_i\le 10^9$. Translated by ChatGPT 5