atcoder#AGC048F. [AGC048F] 01 Record
[AGC048F] 01 Record
Score : points
Problem Statement
Snuke received a big blackboard. Being pleased with this present, he first wrote some positive integers. Then, he repeated the following operation until there was no integer written on the blackboard:
- Choose one integer written on the blackboard and erase it. Let be the erased integer. Then, record the remainder of divided by on his notebook. Finally, if , write a new integer on the blackboard.
Snuke's record is represented by a string consisting of 0
and 1
, where is the remainder of the chosen integer divided by in the -th operation.
Snuke forgot the combination of positive integers he first wrote on the blackboard. From the information given as the string , find the number of possible combinations of positive integers he first wrote on the blackboard. Here, we consider combinations and of positive integers different when there is an integer such that the numbers of times occurs in and occurs in differ. Since the count can be enormous, compute it modulo . Also, it is possible that Snuke's record is incorrect and that no combination of positive integers satisfies the condition. In such a case, just answer .
Constraints
- is a string consisting of
0
and1
.
Input
Input is given from Standard Input in the following format:
Output
Print the number of possible combinations of positive integers written on the blackboard, modulo .
101
2
There are two possible combinations of integers written on the blackboard: and .
100
0
There is no possible combination of integers written on the blackboard.
010101
3
There are three possible combinations of integers written on the blackboard: , , and .
11101000111110111101001011110010111110101111110111
3904