P8708 [Lanqiao Cup 2020 NOI Qualifier A1] Small Integer Concatenation.

Description

Given an array $A_1, A_2, \cdots, A_n$ of length $n$. You can choose two numbers $A_i$ and $A_j$ ($i \neq j$), then concatenate $A_i$ and $A_j$ in order to form a new integer. For example, `12` and `345` can be concatenated into `12345` or `34512`. Note that swapping the order of $A_i$ and $A_j$ is always considered as $2$ different ways, even when $A_i = A_j$. Please calculate how many concatenations produce an integer that is less than or equal to $K$.

Input Format

The first line contains $2$ integers $n$ and $K$. The second line contains $n$ integers $A_1, A_2, \cdots, A_n$.

Output Format

Output one integer representing the answer.

Explanation/Hint

For $30\%$ of the test cases, $1 \le n \le 1000$, $1 \le k \le 10^8$, $1 \le A_i \le 10^4$. For all test cases, $1 \le n \le 10^5$, $1 \le k \le 10^{10}$, $1 \le A_i \le 10^9$. Lanqiao Cup 2020, first round of the provincial contest, Group A, Problem H. Translated by ChatGPT 5