Recurrence f=a+2b
The sequence obeys f(0)=1,f(1)=2,f(n)=f(n−1)+2f(n−2). Print f(N) modulo 109+7.
Input: one integer N.
Output: f(N) mod 109+7.
Constraints:
- 0 ≤ N ≤ 1018
Sample Tests
Input 1
5
Output 1
32
Input 2
0
Output 2
1
Input 3
1
Output 3
2
Discussion (opens after you solve — no spoilers before)
No comments yet.