#P3276. [SCOI2011] 镜像拆分
[SCOI2011] 镜像拆分
Description
lxhgww loves number games. He discovered that many numbers can be expressed as the sum of two numbers that are reverses of each other; he calls this phenomenon a number’s “mirror decomposition”. For example, has five mirror decompositions: . Note that leading zeros are not allowed, so is not counted as a valid mirror decomposition. Now lxhgww wants to know, in base , for the numbers in the interval , what is the sum of the counts of their mirror decompositions?
Input Format
The first line of input is a number . The second line is a number , denoting the length of the number . The next lines give each digit of starting from the least significant digit. Then comes a number , denoting the length of the number . The next lines give each digit of starting from the least significant digit.
Output Format
Output one line containing an integer, which is the sum of the counts of mirror decompositions. Since the answer can be very large, output the remainder when this answer is divided by .
10
2
6
6
2
6
6
5
Hint
- For of the testdata, it is guaranteed that: , .
- For of the testdata, it is guaranteed that: , .
- For of the testdata, it is guaranteed that: , .
- For all the testdata, it is guaranteed that: . Each digit of and is in the range , and there are no leading zeros.
Translated by ChatGPT 5
京公网安备 11011102002149号