Yesterday on BSUIR Open i found this problem: Given array $$$a$$$ size $$$n$$$ and $$$q$$$ queries:
- Given two integers $$$l,r,$$$ calculate $$$\sum_i^{r-l+1} a_{l+i}*fib_i$$$ modulo $$$10^9+7$$$, where $$$fib_i$$$ — $$$i$$$-th number in Fibonacci sequence.
- Given three integers $$$l,r,x$$$, add $$$x$$$ on segment from $$$l$$$ to $$$r$$$.
But while solving I never used the fact that given coeficients are Fibonacci numbers, and was solving general case, which I couldn't do, and now I become intrested, is it possible to solve general case problem faster $$$O(nq)$$$, or prove the reverse?
More formally: Given array $$$a$$$, and also array $$$c$$$, both size $$$n$$$ and $$$q$$$ queries:
- Given two integers $$$l,r,$$$ find $$$\sum_i^{r-l+1} a_{l+i}*c_i$$$ modulo $$$10^9+7$$$.
- Given three integers $$$l,r,x$$$, add $$$x$$$ on segment from $$$l$$$ to $$$r$$$.
Can you help?