logo AlgoBeat OnlineJudge
登录 注册

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

内存限制:1024 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You are given a set of integers . As long as does not contain , you can repeatedly perform the following operation:

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

Determine the maximum number of operations that can be performed.

输入格式

The input consists of multiple test cases.

The first line contains an integer (), representing the number of test cases.

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

For each test case, the only line contains integers and (), representing the minimum and maximum values of the set, respectively.

输出格式

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

样例

样例输入 1

3
7 10
1 2718
20250913 20250915

样例输出 1

2
1
23