#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 1,2,3,5,8,13,21,1,2,3,5,8,13,21,\ldots.

For a positive integer pp, define X(p)X(p) as the number of ways to represent pp 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 a1,a2,,ana_1,a_2,\ldots,a_n of length nn, for a non-empty prefix a1,a2,,aka_1,a_2,\ldots,a_k, we define pk=Fa1+Fa2++Fakp_k=F_{a_1}+F_{a_2}+\cdots+F_{a_k}.

Your task is: for all k=1,2,,nk=1,2,\ldots,n, compute X(pk)X(p_k) modulo 109+710^9+7.

Input Format

The first line of standard input contains an integer nn.

The second line contains nn integers a1,a2,,ana_1,a_2,\ldots,a_n separated by spaces.

Output Format

Standard output should contain nn lines. On the kk-th line, output X(pk)X(p_k) modulo 109+710^9+7.

4
4 1 1 5
2
2
1
2

Hint

Sample Explanation

The values of pkp_k 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}$$

55 can be represented in two ways: F2+F3F_2+F_3 and F4F_4 alone (that is, 2+32+3 and 55), so X(p1)=2X(p_1)=2.

We have X(p2)=2X(p_2)=2 because p2=1+5=2+3p_2=1+5=2+3.

The only representation of 77 as a sum of distinct Fibonacci numbers is 2+52+5.

Finally, 1515 can be represented as 2+132+13 and 2+5+82+5+8 (two representations).

Constraints

For 100%100\% of the testdata, 1n105, 1ai1091\le n\le 10^5,\ 1\le a_i\le 10^9.

All testdata are divided into the following subtasks with additional restrictions. Each subtask contains several test points.

Subtask Additional Restrictions Points
11 n,ai15n, a_i \leq 15 55
22 n,ai100n, a_i \leq 100 2020
33 n100n \leq 100, and aia_i are distinct perfect squares 1515
44 n100n \leq 100 1010
55 aia_i are distinct even numbers 1515
66 No additional restrictions 3535

Translated by ChatGPT 5