#P11140. [APC001] E - Linear Map
[APC001] E - Linear Map
Background
Please note the special time limit of this problem, and use faster input/output methods as appropriate.
In the vast world of florr, there is an unknown corner. It was built to make it easy to quickly test new mobs. Now it has been abandoned, but it has not disappeared.
The adventurer MF found this place and discovered its name: Linear map.
Problem Description
Linear map can be seen as a string, where each character is a digit from .
MF thinks that if a string has two different intervals, both with length , whose digit sums are equal, then this string is boring.
For example, is a boring string because , and is also a boring string because . In contrast, and are not boring strings.
MF plans to split Linear map into several non-empty, continuous, and non-overlapping segments. These segments cover all characters of the string, and every segment must not be a boring string.
MF is an interesting person, so it wants to count the number of valid splitting ways, modulo .
Input Format
One line containing a string .
Output Format
One line containing an integer, the answer modulo .
453
4
3333
5
9475739582850286
9360
Hint
Sample Explanation
- Sample
All splits are valid: .
- Sample
The valid splits are: $\{33,33\},\{33,3,3\},\{3,33,3\},\{3,3,33\},\{3,3,3,3\}$.
Constraints
For of the data, , and contains only digits.
Translated by ChatGPT 5