[Solution] Antifibonacci Cut Codeforces Solution
Note that the memory limit is unusual.
Let's define the sequence of Fibonacci strings as follows: is 0, is 1, is for ( denotes the concatenation of two strings). So, for example, is 10, is 101, is 10110.
For a given string , let's define as the number of ways to cut it into several (any number, possibly even just one) strings such that none of these strings are Fibonacci strings. For example, if is 10110101, since there are three ways to cut it:
- 101101 01;
- 1011 0101;
- 1011 01 01.
You are given a sequence of strings . Calculate . Since these values can be huge, print them modulo .
The first line of the input contains one integer ().
Then, lines follow. The -th line contains the string (), consisting of characters 0 and/or 1.
Print integers, where the -th integer is .
No comments:
Post a Comment