Upload code_segments/segment_13.txt with huggingface_hub
Browse files- code_segments/segment_13.txt +19 -0
code_segments/segment_13.txt
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The two versions are different problems. You may want to read both versions. You can make hacks only if both versions are solved.
|
| 2 |
+
|
| 3 |
+
You are given two positive integers $n$, $m$.
|
| 4 |
+
|
| 5 |
+
Calculate the number of ordered pairs $(a, b)$ satisfying the following conditions:
|
| 6 |
+
|
| 7 |
+
* $1\le a\le n$, $1\le b\le m$; * $b \cdot \gcd(a,b)$ is a multiple of $a+b$.
|
| 8 |
+
|
| 9 |
+
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.
|
| 10 |
+
|
| 11 |
+
The first line of each test case contains two integers $n$, $m$ ($1\le n,m\le 2 \cdot 10^6$).
|
| 12 |
+
|
| 13 |
+
It is guaranteed that neither the sum of $n$ nor the sum of $m$ over all test cases exceeds $2 \cdot 10^6$.
|
| 14 |
+
|
| 15 |
+
For each test case, print a single integer: the number of valid pairs.
|
| 16 |
+
|
| 17 |
+
In the first test case, no pair satisfies the conditions.
|
| 18 |
+
|
| 19 |
+
In the fourth test case, $(2,2),(3,6),(4,4),(6,3),(6,6),(8,8)$ satisfy the conditions.
|