Growth Function values <PB>
Practice
1 (1 votes)
Recruit
Approved
Ready
Easy
Grammar Verified
Mathematics
Matrix exponentiation
Problem
30% Success 96 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

A new business growth estimate function named \(f(x)\) is out in the market which depends on a particular strategy and counts the total revenue that can be generated over x number of years. The function is defined as:

\(f (x)\) = 1, when x = 1
\(f (x)\) = 2, when x = 2
\(f (x)\) = 5, when x = 3
\(f (x)\) = 12, when x = 4
\(f (x)\) = \(f (x-1)\) + 2 * \(f (x-2)\) + 3 * \(f (x - 3 )\) + \(f (x - 4 )\), when x > 4

Ryan is working for the company Pitney Bowes and he is assigned the task to calculate the value of this function so that PB can estimate the profit. Since the function is too complex and he does not wants to defame his image so he asks you for the help. Now you are given an integer N by Ryan and you have to find the value of \(f(N)\) based on the conditions above.
Since the output can be large, print the answer Modulo \( 10^9+7 \).

Input format

  • First line: T (number of test cases)
    For each test case
  • First line: N

Output format

For each test case, print the value of \(f(N)\) Modulo \( 10^9+7 \).

Constraints

\(1 \le T \le 10^{4}\)
\(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:20
20 votes
Tags:
AlgorithmsDepth First SearchEasyGraphs
Points:30
Tags:
AlgorithmsGame TheoryMedium
Points:20
Tags:
EasyMath