QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 512 MB Points totaux : 100

#11080. 数字划分

Statistiques

给定一个包含 $n$ 个十进制数字的序列。该序列需要被划分为一个或多个连续的子序列,使得每个子序列在被解释为十进制数时,都能被给定的整数 $m$ 整除。

求出满足条件的划分方案总数,结果对 $10^9 + 7$ 取模。在判断两个划分方案是否不同时,我们仅考虑子序列边界的位置,而不考虑数字本身,例如划分 $2|22$ 和 $22|2$ 被视为不同的方案。

输入格式

第一行包含两个整数 $n$ 和 $m$ ($1 \le n \le 300\,000$, $1 \le m \le 1\,000\,000$),分别表示序列的长度和除数。第二行包含一个由恰好 $n$ 个数字组成的字符串。

输出格式

输出一个整数,表示满足条件的划分方案总数,结果对 $10^9 + 7$ 取模。

样例

样例输入 1

4 2
1246

样例输出 1

4

样例输入 2

4 7
2015

样例输出 2

0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.