Pirate Code
Time limit2sMemory limit1024 MB
For each length k up to n, sum the decoded values of all binary codes of length k under Fibonacci pirate splitting, modulo 10^9+7.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Combinatorics, String
- Solved
- No attempts yet
Statement
Captain Marrrtina and her pirate crew spent three months searching for the long lost treasure of the most famous Italian pirate, and finally dug up a chest full of gold. To unlock the chest, she needs a secret combination. It is described in a message in a bottle next to the chest.
The message says:

So that only the most worthy pirate can open the chest, the combination is the solution to the following puzzle. A binary sequence of length in which the only pair of consecutive ones is at the end of the sequence is a pirate representation of a number if
where denotes the -th Fibonacci number. Fibonacci numbers are defined by , , and for each .
For example, , , , where denotes a pirate representation of a number.
A pirate code is a binary sequence (with no restriction on consecutive ones) that represents a sequence of positive integers. To read it, split it into as many parts as possible, where each part is a pirate representation of some number. A suffix that is not a pirate representation of any number may be left over, and it is discarded. The integers of the parts are then written in order. For example, split into 011|11|01011|0101. The last part is not a pirate representation, so it is dropped, leaving 011|11|01011, which reads as the sequence , , .
The value of a pirate code is the sum of the values of the decoded sequence of positive integers. The value of the code above is .
My favourite number is the sum of the values of all pirate codes of length . Since that number may be large, the combination to the chest is the remainder of modulo .
If Marrrtina does not open the chest, her crew will not consider her worthy and will make her walk the plank.
- Leonarrrdo da Pisa
Input
A single line contains a positive integer .
Output
Print numbers on a single line, where the -th number is the answer to the puzzle for codes of length .
Clarification
Codes of length are and , and both have value .
Code has value , and all other codes of length have value .
Code has value , and code has value .