1967B1.md (1325B)
1 Source: https://codeforces.com/problemset/problem/1967/B1 2 3 B1. Reverse Card (Easy Version) 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 The two versions are different problems. You may want to read both versions. You can make hacks only if both versions are solved. 22 23 You are given two positive integers $n$, $m$. 24 25 Calculate the number of ordered pairs $(a, b)$ satisfying the following conditions: 26 27 * $1\le a\le n$, $1\le b\le m$; 28 * $a+b$ is a multiple of $b \cdot \gcd(a,b)$. 29 30 Input 31 32 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. 33 34 The first line of each test case contains two integers $n$, $m$ ($1\le n,m\le 2 \cdot 10^6$). 35 36 It is guaranteed that neither the sum of $n$ nor the sum of $m$ over all test cases exceeds $2 \cdot 10^6$. 37 38 Output 39 40 For each test case, print a single integer: the number of valid pairs. 41 42 Example 43 44 Input 45 46 ``` 47 6 48 49 1 1 50 51 2 3 52 53 3 5 54 55 10 8 56 57 100 1233 58 59 1000000 1145141 60 ``` 61 62 Output 63 64 ``` 65 1 66 67 3 68 69 4 70 71 14 72 73 153 74 75 1643498 76 ``` 77 78 Note 79 80 In the first test case, only $(1,1)$ satisfies the conditions. 81 82 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.