The value of an equation

2.6

9 votes
Linear Algebra, Dynamic Programming, Algorithms, Matrix Exponentiation, Math
Problem

You are given T tests and each test contains a number n. Your task is to determine the value of the following expression: 

ni=0[F(i)]2

F(0)=0, F(1)=1, F(2)=1, ..., F(n)=F(n1)+F(n2) 

Input format

  • The first line contains a number T .
  • Next T lines contain T queries.

Output format

Print the answer as described in the problem mod 1e9+7.

Constraints

1T1051N1018    

Sample Input
3
0
1
3
Sample Output
0
1
6
Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

The first sample 

  •  f[0]^2 = 0^2 = 0
  •  f[0]^2 + f[1]^2 = 0 + 1 = 1
  •  f[0]^2 + f[1]^2 + f[2]^2 + f[3]^2 = 0 + 1 + 1 + 4 = 6

 

Editor Image

?