Semi-equations
Practice
4.2 (5 votes)
Linear algebra
Algorithms
Matrix exponentiation
Math
Problem
15% Success 2061 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code
You are given $$t$$ test cases. Each test case contains an integer $$n$$. Find the value of the following function:
such that
- \(f[0] = 0, f[1]=1, f[2]=1 ,....,f[n]=f[n-1]+f[n-2]. \)
Formally, you are required to find the summation from $$i=0$$ to $$i=n$$ for $${f[i]}$$.
Input format
- The first line contains an integer $$t$$ denoting the number of test cases.
- Each of the next $$t$$ lines contains an integer $$n$$.
Output format
Print the answer as described above modulo $$10^9+7$$.
Constraints
$$1 \le t \le 10^5$$
$$1 \le n \le {10^{18}}$$
Sample Input
2 1 7
Sample Output
1 33
Explanation
In the first test case we have n=1 so we have to find the summation of f[0]+f[1] = 0+1 = 1,
also the second test case the answer will be 0+1+1+2+3+5+8+13 = 33.
Code Editor
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
Submissions
Please login to view your submissions
Similar Problems
1.Reverse
Points:30
39 votes
Tags:
Linear AlgebraApprovedEasy-MediumReadyMathematicsMatrix Exponentiation
Editorial
Login to unlock the editorial
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