#P6371. [COCI 2006/2007 #6] V
[COCI 2006/2007 #6] V
Problem Description
Using the given digits, form some numbers in such that each of these numbers is divisible by .
Input Format
The first line contains three integers .
The second line is a digit string, indicating the digits that can be used. A digit can be used multiple times, and the digits will not be repeated.
Output Format
Output one integer in one line, indicating how many numbers in that can be formed using the given digits are divisible by .
2 1 20
0123456789
10
6 100 9294
23689
111
5 4395 9999999999
12346789
0
Hint
Constraints
- For of the testdata, it is guaranteed that , .
Notes
This problem is translated from COCI2006-2007 CONTEST #6 T5 V。
Translated by ChatGPT 5