#P9151. 计数题
计数题
Background
身のうさを思ひしらでややみなまし そむくならひのなき世なりせば
Problem Description
Given a binary string of length , you can perform some operations. In each operation, choose a substring of length and replace it with its median (note that it becomes a single digit). Ask how many different strings can be obtained.
Output the answer modulo .
Input Format
This problem has multiple test cases. The first line contains the number of test cases .
For each test case, input only one string , representing the given binary string.
Output Format
For each test case, output one integer per line, which is the answer modulo .
4
1001
111000
101010
111000101010
3
7
3
25
Hint
Sample Explanation
It can be proven that can only obtain the strings , , and through the operations, so the answer for the first test case in the sample is .
Constraints
For of the testdata, , , and .
| Subtask | Special Property | Score | |
|---|---|---|---|
| 1 | |||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | A | ||
| 6 | B | ||
| 7 | |||
| 8 |
Special Property A: It is guaranteed that .
Special Property B: It is guaranteed that and .
String indices start from .
Translated by ChatGPT 5