Codeforces Round 942 (Div. 1)
B1
Reverse Card (Easy Version)
Codeforces
1400
原题
← AB2 →
翻译中…

The two versions are different problems. You may want to read both versions. You can make hacks only if both versions are solved.

翻译中…

You are given two positive integers $n$, $m$.

翻译中…

Calculate the number of ordered pairs $(a, b)$ satisfying the following conditions:

翻译中…
  • $1\le a\le n$, $1\le b\le m$;
  • $a+b$ is a multiple of $b \cdot \gcd(a,b)$.
翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1\le t\le 10^4$). The description of the test cases follows.

翻译中…

The first line of each test case contains two integers $n$, $m$ ($1\le n,m\le 2 \cdot 10^6$).

翻译中…

It is guaranteed that neither the sum of $n$ nor the sum of $m$ over all test cases exceeds $2 \cdot 10^6$.

翻译中…

Output

翻译中…

For each test case, print a single integer: the number of valid pairs.

翻译中…

Note

翻译中…

In the first test case, only $(1,1)$ satisfies the conditions.

翻译中…

In the fourth test case, $(1,1),(2,1),(2,2),(3,1),(4,1),(5,1),(6,1),(6,2),(6,3),(7,1),(8,1),(9,1),(10,1),(10,2)$ satisfy the conditions.

翻译中…

样例

Input #1
6
1 1
2 3
3 5
10 8
100 1233
1000000 1145141
Output #1
1
3
4
14
153
1643498
InputCopy OutputCopy
题目信息
题号
1967B1
时间限制
2 s
内存限制
256 MB
标签
暴力
数学
数论

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