Codeforces Round 846 (Div. 2)
E
Josuke and Complete Graph
Codeforces
2400
原题
← DF →
翻译中…

Josuke received a huge undirected weighted complete$^\dagger$ graph $G$ as a gift from his grandfather. The graph contains $10^{18}$ vertices. The peculiarity of the gift is that the weight of the edge between the different vertices $u$ and $v$ is equal to $\gcd(u, v)^\ddagger$. Josuke decided to experiment and make a new graph $G'$. To do this, he chooses two integers $l \le r$ and deletes all vertices except such vertices $v$ that $l \le v \le r$, and also deletes all the edges except between the remaining vertices.

翻译中…

Now Josuke is wondering how many different weights are there in $G'$. Since their count turned out to be huge, he asks for your help.

翻译中…

$^\dagger$ A complete graph is a simple undirected graph in which every pair of distinct vertices is adjacent.

翻译中…

$^\ddagger$ $\gcd(x, y)$ denotes the greatest common divisor (GCD) of the numbers $x$ and $y$.

翻译中…

Input

翻译中…

The first line contains one integer $t$ ($1 \le t \le 100$) — the number of test cases.

翻译中…

The first line of each test case contains two numbers $l$, $r$ ($1 \le l \le r \le 10^{18}$, $l \le 10^9$).

翻译中…

Output

翻译中…

For each test case print a single number — the number of different weights among the remaining edges.

翻译中…

Note

翻译中…

image The graph $G'$ for the first test case.

翻译中…

The picture above shows that the graph has $2$ different weights.

翻译中…

In the fifth test case, there is only one vertex from which no edges originate, so the answer is $0$.

翻译中…

样例

Input #1
7
2 4
16 24
2 6
1 10
3 3
2562 2568
125 100090
Output #1
2
6
3
5
0
5
50045
InputCopy OutputCopy
题目信息
题号
1780E
时间限制
2 s
内存限制
256 MB
标签
二分
暴力
数据结构
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。