#P15785. [JAG 2025 Summer Camp #3] Max of Mod

[JAG 2025 Summer Camp #3] Max of Mod

题目描述

You are given a set of integers S={L,L+1,,R}S = \{L, L+1, \ldots, R\}. As long as SS does not contain 00, you can repeatedly perform the following operation:

Choose a positive integer gg less than or equal to the maximum value in SS, and replace each element of SS with its remainder when divided by gg.

Determine the maximum number of operations that can be performed.

输入格式

The input consists of multiple test cases.

The first line contains an integer TT (1T1000001 \leq T \leq 100\,000), representing the number of test cases.

TT test cases follow. Each test case is given in the following format.

L RL \ R

For each test case, the only line contains integers LL and RR (1LR1091 \leq L \leq R \leq 10^9), representing the minimum and maximum values of the set, respectively.

输出格式

For the TT test cases, output the answers separated by newlines. For each test case, output the maximum number of operations that can be performed.

3
7 10
1 2718
20250913 20250915
2
1
23