#H. F - Variety of Digits

    传统题 3000ms 1024MiB

F - Variety of Digits

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

F - Variety of Digits

Score : $500$ points

Problem Statement

Given are $M$ digits $C_i$.

Find the sum, modulo $998244353$, of all integers between $1$ and $N$ (inclusive) that contain all of $C_1, \ldots, C_M$ when written in base $10$ without unnecessary leading zeros.

Constraints

  • $1 \leq N < 10^{10^4}$
  • $1 \leq M \leq 10$
  • $0 \leq C_1 < \ldots < C_M \leq 9$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

MM

C1C_1 \ldots CMC_M

Output

Print the answer.


104
2
0 1
520

Between $1$ and $104$, there are six integers that contain both 0 and 1 when written in base $10$: $10,100,101,102,103,104$.
The sum of them is $520$.


999
4
1 2 3 4
0

Between $1$ and $999$, no integer contains all of 1, 2, 3, 4.


1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
5
0 2 4 6 8
397365274

Be sure to find the sum modulo $998244353$.

2024春季入门组刷题营(十一)

未参加
状态
已结束
规则
IOI
题目
8
开始于
2024-5-26 13:00
结束于
2024-5-26 15:00
持续时间
2 小时
主持人
参赛人数
10