#2800. [HBCPC2024] LCMs

    ID: 2800 传统题 1000ms 256MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>P10869数学2024O2优化最短路省赛/邀请赛湖北

[HBCPC2024] LCMs

[HBCPC2024] LCMs

题目描述

Walk Alone has a number axis with only positive integers on it. The cost of walking from point on integer $a$ to point on integer $b$ is ${\rm lcm}(a, b)$, where ${\rm lcm}(a, b)$ means the least common multiple of integers $a$ and $b$. Due to the hatred of the integer $1$, Walk Alone forbids anyone from moving to points on integers $\textbf{smaller than or equal to}$ $1$.

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

输入格式

There are $T$ ($1 \le T \le 1000$) test cases.

In each test case, there is only one line containing two integers aa and bb (2≤a≤b≤1072 \le a \le b \le 10^7), denoting the start and end point.

输出格式

For each test case, output a single integer denoting the minimal cost.
3
3 4
10 15
2 4
10
25
4

提示

In the first test case, you can walk such a path: $3 \to 2 \to 4$, where the total cost is ${\rm lcm}(3, 2) + {\rm lcm}(2, 4) = 6 + 4 = 10$, which can be proved to be the minimum. 标签: P10869|数学|2024|O2优化|最短路|省赛/邀请赛|湖北

来源

P10869|[HBCPC2024] LCMs