P21810 [GeeksforGeeks] Matrix exponentiation2711
普及
题目描述

Given an equation of the form f(n) = f(n-1) + f(n-2) where f(0) = 1, f(1) = 1 , the task is to find the n^{th} term of this sequence.

Example 1:
Input: n = 3
Output: 3
Explanation: f(3) = f(2) + f(1) = 3
Example 2:
Input: n = 2
Output: 2
Explanation: f(2) = f(1) + f(0) = 2

Yout Task:
You don't need to read or print anything. Your task is to complete the function FindNthTerm() which takes n as input parameter and returns n^{th} term mod 10^9+7 .
Expected Time Complexity: O(log(n))
Expected Space Complexity: O(K) where K is constant.

Constraints:
1 <= n <= 10^{9}

输入格式

见题面

输出格式

见题面

样例输入
n = 3
样例输出
3