Sunnie has an array of integers $A$ of length $N$. She creates a new array $B$: for each pair of elements in $A$, she adds their product to the array $B$. Now, Sunnie wants to know how many elements in $B$ contain the digit $K$.
Input
The first line of input contains two integers $N$ and $K$.
The second line of input contains $N$ integers, the elements of $A$.
Output
Output a single integer: the number of elements in $B$ containing the digit $K$.
Hint
The number of pairs that can be chosen from $N$ elements is $\frac{N(N-1)}{2}$.
Constraints
For all subtasks, $0 \le K \le 9$, $1 \le A_i \le 10^3$.
Subtask 1 (50%): $2 \le N \le 10^3$
Subtask 2 (50%): $2 \le N \le 10^5$
Sample Test Cases
Input | Output | |
---|---|---|
4 8 5 9 14 17 |
2 | |
$B = \{45, 70, 85, 126, 153, 238\}$
$85$ and $238$ contain the digit $8$. |
||
4 1 1 1 1 1 |
6 | |
$B = \{1, 1, 1, 1, 1, 1\}$
All elements of $B$ contain the digit $1$. |
Scoring: Per Subtask
Authored by s16f22
Appeared in 2022 Mini Contest 0