logo AlgoBeat OnlineJudge
登录 注册

#210718. [HBCPC2024] LCMs

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

题目描述

Walk Alone has a number axis with only positive integers on it. The cost of walking from point on integer to point on integer is , where means the least common multiple of integers and . Due to the hatred of the integer , Walk Alone forbids anyone from moving to points on integers .

Given two integers and , you need to calculate the minimal cost of walking from point on integer to .

输入格式

There are () test cases.

In each test case, there is only one line containing two integers and (), denoting the start and end point.

输出格式

For each test case, output a single integer denoting the minimal cost.

样例

样例输入 1

3
3 4
10 15
2 4

样例输出 1

10
25
4

数据范围与提示

In the first test case, you can walk such a path: , where the total cost is , which can be proved to be the minimum.