H - Queries with recurrences
Languages: C, C++, Java, Python, Kotlin, C#
Time & Memory limits:
(details)
Problems involving queries and recurrences are very common in ICPC. In this problem, we are going to mix a little both topics. Given the recurrence $F_n = a \times F_{n-1} + b \times F_{n-2} + k$ and an array $A$ with $N$ values, write a program to perform $Q$ queries with the following format:
- 1 $a$ $b$ $k$: Increase each value in array $A$ whose position is within the range $[a,b]$ with the value $F_n$, where $n = a \times b$ ($1 \le a \le b \le N$, $1 \le k \le 2N$).
- 2 $a$ $b$: Return the sum of values $A_a + A_{a+1} + ... + A_b$. This value can be very big, so print the answer modulo $1000000007$. ($1 \le a \le b \le N$).