CEOI '18 P4 - Fibonacci Representations

View as PDF

Submit solution


Points: 40 (partial)
Time limit: 1.8s
Memory limit: 256M

Problem types

Let us define the sequence of Fibonacci numbers as: F1=1F2=2Fn=Fn1+Fn2 for n3

The first few elements of the sequence are 1,2,3,5,8,13,21,

For a positive integer p, let X(p) denote the number of different ways of expressing p as a sum of different Fibonacci numbers. Two ways are considered different if there is a Fibonacci number that exists in exactly one of them.

You are given a sequence of n positive integers a1,a2,,an. For a non-empty prefix a1,a2,,ak, we define pk=Fa1+Fa2++Fak. Your task is to find the values X(pk) modulo 109+7, for all k=1,,n.

Input

The first line of the standard input contains an integer n (1n100000). The second line contains n space-separated integers a1,a2,,an (1ai109).

Output

The standard output should contain n lines. In the k-th line, print the value X(pk) modulo (109+7).

Grading

The test set is divided into the following subtasks with additional constraints. Tests in each of the subtasks consist of one or more separate test groups. Each test group may contain one or more test cases.

Subtask Constraints Points
1 n,ai15 5
2 n,ai100 20
3 n100, ai are squares of different natural numbers 15
4 n100 10
5 ai are different even numbers 15
6 no additional constraints 35

Sample Input 1

Copy
4
4 1 1 5

Sample Output 1

Copy
2
2
1
2

Explanation of Sample Output 1

p1=F4=5

p2=F4+F1=5+1=6

p3=F4+F1+F1=5+1+1=7

p4=F4+F1+F1+F5=5+1+1+8=15

The number 5 can be expressed in two ways: as F2+F3 and simply as F4 (that is, 2+3 and 5, respectively).

Hence, X(p1)=2.

Then we have X(p2)=2 because p2=1+5=1+2+3.

The only way to express 7 as a sum of different Fibonacci numbers is 2+5.

Finally, 15 can be expressed as 2+13 and 2+5+8 (two ways).


Comments

There are no comments at the moment.