#abc235f. F - Variety of Digits
F - Variety of Digits
Score : points
问题描述
已知 个数字 。
求在十进制表示下,包含所有 的整数(不包含前导零)从 到 (包含)的和,对 取模的结果。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Given are digits .
Find the sum, modulo , of all integers between and (inclusive) that contain all of when written in base without unnecessary leading zeros.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
104
2
0 1
Sample Output 1
520
Between and , there are six integers that contain both 0
and 1
when written in base : .
The sum of them is .
Sample Input 2
999
4
1 2 3 4
Sample Output 2
0
Between and , no integer contains all of 1
, 2
, 3
, 4
.
Sample Input 3
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
5
0 2 4 6 8
Sample Output 3
397365274
Be sure to find the sum modulo .
update @ 2024/3/10 10:12:30