P20798 [GeeksforGeeks] Modified fibonacci4449
普及-
题目描述

Given 4 integers A, B, C and N, find the value of F(N) such that
F(1) = A + B
F(2) = B + C
F(N) = F(N-1) - F(N-2), for N > 2.

Example 1:
Input: N = 2, A = 2, B = 3, C = 4
Output: 7
Explaination: F(2) = B+C = 3+4 = 7
Example 2:
Input: N = 3, A = 2, B = 3, C = 4
Output: 2
Explaination: F(3) = F(2)- F(1) = 7-5 = 2
Your Task:
You do not need to read input or print anything. Your task is to complete the function modifiedFib() which takes the values N, A, B and C as input parameters and returns F(N). Since F(N) modulo (10^{9}+7).
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 10^{12}
1 ≤ A, B, C ≤ 10^{9}

输入格式

见题面

输出格式

见题面

样例输入
N = 2, A = 2, B = 3, C = 4
样例输出
7