Recursion [II]
Recursion [II]
We introduce a new recursive sequence, which satisfies:
⎩<svg xmlns="http://www.w3.org/2000/svg" width="0.8889em" height="0.316em" style="width:0.8889em" viewBox="0 0 888.89 316" preserveAspectRatio="xMinYMin"><path d="M384 0 H504 V316 H384z M384 0 H504 V316 H384z"></svg>⎨<svg xmlns="http://www.w3.org/2000/svg" width="0.8889em" height="0.316em" style="width:0.8889em" viewBox="0 0 888.89 316" preserveAspectRatio="xMinYMin"><path d="M384 0 H504 V316 H384z M384 0 H504 V316 H384z"></svg>⎧G(0)=0G(1)=5G(n)=2×G(n−1)+3×G(n−2)+F(n−1)n≥2Where F(n) is the nth fibonacci number, following the previous definition.
For example, G(0),G(1),G(2),G(3),G(4) can be written as 0,5,11,39,114
In this question, you must compute G(n) for some value n. Since the value may be quite large, output your answer modulo 109+7.
Input
Input will contain a single integer n
Output
Output should contain a single integer, representing G(n)mod109+7.
Constraints
- 0≤n≤1018
Example
5
350
Comments0
No comments yet
Be the first to comment.
New comment
Log in to join the discussion.