#P3311. [SDOI2014] 数数
[SDOI2014] 数数
Description
We call a positive integer a lucky number if and only if its decimal representation does not contain any element from the set as a substring. For example, when , is a lucky number, while , , and are not. Given and , compute the number of lucky numbers not greater than .
The answer is taken modulo .
Input Format
The first line contains an integer .
The second line contains an integer , the number of elements in .
The next lines each contain a digit string , representing an element of .
Output Format
Output a single line containing one integer, the answer modulo .
20
3
2
3
14
14
Hint
Sample 1 Explanation
Except for , all integers not exceeding are lucky numbers.
Constraints
For all testdata, it is guaranteed that:
, , , , where denotes the length of string . has no leading , but may have leading .
Translated by ChatGPT 5
京公网安备 11011102002149号