201120: [AtCoder]ARC112 A - B = C

Memory Limit:1024 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $300$ points

Problem Statement

How many triples $A,B,C$ of integers between $L$ and $R$ (inclusive) satisfy $A-B=C$?

You will be given $T$ cases. Solve each of them.

Constraints

  • $1 \leq T \leq 2\times 10^4$
  • $0\le L \le R \le 10^6$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$T$
$\text{case}_1$
$\vdots$
$\text{case}_T$

Each case is in the following format:

$L$ $R$

Output

Print $T$ values; the $i$-th of them should be the answer for $\text{case}_i$.


Sample Input 1

5
2 6
0 0
1000000 1000000
12345 67890
0 1000000

Sample Output 1

6
1
0
933184801
500001500001

In the first case, we have the following six triples:

  • $4 - 2 = 2$
  • $5 - 2 = 3$
  • $5 - 3 = 2$
  • $6 - 2 = 4$
  • $6 - 3 = 3$
  • $6 - 4 = 2$

Input

题意翻译

给出 $t$ 组测试数据,第 $i$ 组数据包含两个数 $l_i$ 和 $r_i$ 。对于每组数据,请输出由在 $l_i$ 和 $r_i$ 之间(含 $l_i$ 和 $r_i$ )的三个整数 $a,b,c$ 组成的满足 $a-b=c$ 的三元组 $(a,b,c)$ 的个数。

加入题单

上一题 下一题 算法标签: