Fibonacci product
InterviewTime limit1sMemory limit1024 MB
Given n, count the ways to write it as a product of Fibonacci numbers greater than 1, where order does not matter.
- Level
Medium5 of 10
- Topics
- Backtracking, Recursion, Math
- Solved
- No attempts yet
Statement
The Fibonacci sequence is defined as follows: , , . The sequence begins .
A natural number is given. Count the number of ways to write as a product of Fibonacci numbers, each greater than 1.
Input
The first line contains an integer , the number of test cases (). Each of the next lines contains one integer ().
Output
For each test case, print the number of ways on a separate line.
Hint
In the example, the number 2 can be written as a product of Fibonacci numbers in exactly one way: . The number 7 cannot be written as a product of Fibonacci numbers. The number 8 can be written in two ways: and . The number 40 can be written in two ways: and .