#P1950. Magic Numbers
Magic Numbers
Magic Numbers
题面翻译
给你 个数 ,保证 位数相同。
问满足以下条件的数 的个数:
-
-
的偶数位是 ,奇数位不是 。 (这里定义偶数位为从高位往低位的数的偶数位)
-
答案对 取模。
$1\le m \le 2000,0\le d \le 9,1\le l \le r \le 10^{2000}$
题目描述
Consider the decimal presentation of an integer. Let's call a number d-magic if digit appears in decimal presentation of the number on even positions and nowhere else.
For example, the numbers , , are 7-magic but , , , , are not 7-magic. On the other hand the number is 0-magic, is 2-magic, is 4-magic and is 1-magic.
Find the number of d-magic numbers in the segment that are multiple of . Because the answer can be very huge you should only find its value modulo (so you should find the remainder after dividing by ).
输入格式
The first line contains two integers ( , ) — the parameters from the problem statement.
The second line contains positive integer in decimal presentation (without leading zeroes).
The third line contains positive integer in decimal presentation (without leading zeroes).
It is guaranteed that , the number of digits in and are the same and don't exceed .
输出格式
Print the only integer — the remainder after dividing by of the number of d-magic numbers in segment that are multiple of .
样例 #1
样例输入 #1
2 6
10
99
样例输出 #1
8
样例 #2
样例输入 #2
2 0
1
9
样例输出 #2
4
样例 #3
样例输入 #3
19 7
1000
9999
样例输出 #3
6
提示
The numbers from the answer of the first example are , , , , , , and .
The numbers from the answer of the second example are , , and .
The numbers from the answer of the third example are , , , , and .