Can any one help me with this problem ? I cannot understand the algorithm .

this problem is directly solved using matrix exponentiation
first we need to write the recurrence in matrix form
|a b c 1| x |t(n-1)|
|1 0 0 0|   |t(n-2)|
|0 1 0 0|   |t(n-3)|
|0 0 0 1|   |d     |
then find pow(n-3) binary exponentiation
if u cant understand this see this link:
link to my solution:

@shakil_ruet The editorial will be posted by tonight

Thanks for the help :slight_smile: @dragonemperor and @pallesai

@shakil_ruet the editorial has been posted