#P6654. [YsOI2020] 归零
[YsOI2020] 归零
Background
Ysuperman especially likes playing counting games.
Actually, this problem was originally planned to be called “亦旧亦久罢以龄”, but I saw that other problem names are all two characters long, so it would not be good to use such a long name.
Problem Description
In his free time, Ysuerpman chooses to kill time with a calculator. He inputs a very long decimal number . How long is it? It has digits in total. For convenience, let the digit on the -th position from low to high be (the index starts from ).
Each time, Ysuerpman will choose a non-zero digit position and perform “rounding”. Specifically, suppose he performs “rounding” on the -th digit:
- If , then subtract from .
- If , then add to , and then subtract .
After several operations, will always become . Now the question is: how many different plans are there that make become ? Two plans are different if and only if there exists some operation where the chosen digit position is different.
Input Format
A high-precision number .
Output Format
The number of different plans that make become , modulo .
5
1
45
2
55
4
3333
24
999999
16336
1919810
3461
11451419
210000
Hint
Sample Explanation
Sample Explanation
There is plan in total.
Sample Explanation
$4\underline{5}\to\underline{5}0\to \underline100 \to 0$
There are plans in total.
Sample Explanation
$\underline{5}5\to\underline{1}05\to\underline{5}\to\underline{1}0 \to 0$
$\underline{5}5\to10\underline{5}\to\underline{1}10\to \underline10 \to 0$
$\underline{5}5\to10\underline{5}\to1\underline{1}0\to \underline100 \to 0$
$5\underline{5}\to\underline{6}0\to \underline100 \to 0$
There are plans in total.
Constraints
This problem uses bundled testdata.
| Score | |||
|---|---|---|---|
For of the data, , and has no leading zeros.
Hint
The time limit for this problem is .
The problem is not hard.
Translated by ChatGPT 5