1288B.md (1055B)
1 Source: https://codeforces.com/problemset/problem/1288/B 2 3 B. Yet Another Meme Problem 4 5 time limit per test 6 7 1 second 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 You are given two integers $A$ and $B$, calculate the number of pairs $(a, b)$ such that $1 \le a \le A$, $1 \le b \le B$, and the equation $a \cdot b + a + b = conc(a, b)$ is true; $conc(a, b)$ is the concatenation of $a$ and $b$ (for example, $conc(12, 23) = 1223$, $conc(100, 11) = 10011$). $a$ and $b$ should not contain leading zeroes. 22 23 Input 24 25 The first line contains $t$ ($1 \le t \le 100$) — the number of test cases. 26 27 Each test case contains two integers $A$ and $B$ $(1 \le A, B \le 10^9)$. 28 29 Output 30 31 Print one integer — the number of pairs $(a, b)$ such that $1 \le a \le A$, $1 \le b \le B$, and the equation $a \cdot b + a + b = conc(a, b)$ is true. 32 33 Example 34 35 Input 36 37 ``` 38 3 39 40 1 11 41 42 4 2 43 44 191 31415926 45 ``` 46 47 Output 48 49 ``` 50 1 51 0 52 1337 53 ``` 54 55 Note 56 57 There is only one suitable pair in the first test case: $a = 1$, $b = 9$ ($1 + 9 + 1 \cdot 9 = 19$).