#P6361. [CEOI 2018] Fibonacci representations
[CEOI 2018] Fibonacci representations
Description
We define the Fibonacci sequence as
$$\begin{aligned} F_1&=1\\ F_2&=2\\ F_n&=F_{n-1}+F_{n-2} \text{ for } n \ge 3 \end{aligned}$$The first several terms of the sequence are .
For a positive integer , define as the number of ways to represent as a sum of several distinct Fibonacci numbers. Two representations are different if and only if there exists a Fibonacci number that appears in exactly one of the two representations.
Given a sequence of positive integers of length , for a non-empty prefix , we define .
Your task is: for all , compute modulo .
Input Format
The first line of standard input contains an integer .
The second line contains integers separated by spaces.
Output Format
Standard output should contain lines. On the -th line, output modulo .
4
4 1 1 5
2
2
1
2
Hint
Sample Explanation
The values of are as follows:
$$\begin{aligned} p_1&=F_4=5\\ p_2&=F_4+F_1=5+1=6\\ p_3&=F_4+F_1+F_1=5+1+1=7\\ p_4&=F_4+F_1+F_1+F_5=5+1+1+8=15 \end{aligned}$$can be represented in two ways: and alone (that is, and ), so .
We have because .
The only representation of as a sum of distinct Fibonacci numbers is .
Finally, can be represented as and (two representations).
Constraints
For of the testdata, .
All testdata are divided into the following subtasks with additional restrictions. Each subtask contains several test points.
| Subtask | Additional Restrictions | Points |
|---|---|---|
| , and are distinct perfect squares | ||
| are distinct even numbers | ||
| No additional restrictions |
Translated by ChatGPT 5
京公网安备 11011102002149号