← All problemsSign in

Devamanyu and Sequences

Devamanyu likes sequences, so Shishir decided to give him a problem to solve. Shishir defines a sequence as: f(1) = 1 f(2) = 1 f(n) = A*f(n-1) + B*f(n-2) , for all n>2 Shishir will ask Q queries to Devamanyu, where each query consist of 4 integers l, r, A and B. For each query Shishir wants Devamanyu to find S(l,r). Where S(l,r) = f(l) + f(l+1) + ...... + f(r-1) + f(r) As this sum can be ve

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start