The value of an equation
Practice
2.6 (9 votes)
Linear algebra
Dynamic programming
Algorithms
Matrix exponentiation
Math
Problem
12% Success 1662 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code

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

\(\Huge\displaystyle\sum_{i=0}^{n} [F(i)]^{2}\)

\(F(0)=0,\ F(1)=1,\ F(2)=1,\ ...,\ F(n) = F(n-1)+F(n-2)\) 

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

\({1 \le T \le 10^5}\\ {1 \le N \le  10^{18}}\\ \)    

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
Tags:
MediumAd-HocLinear AlgebraMatrix ExponentiationAlgorithmsMathematicsOpenApproved
Points:30
1 votes
Tags:
MediumLinear AlgebraMatrix ExponentiationBitmaskAlgorithmsMathematicsOpenApproved
Points:30
1 votes
Tags:
MediumCombinatoricsLinear AlgebraAlgorithmsMathematicsOpenApproved