Help needed in Segment Tree with lazy propagation (updating a range with fibonacci numbers. Div 1. Problem 446 C)

Revision en4, by gi_sha, 2018-08-06 20:20:54

I was trying this question, but repeatedly getting wrong answer on test case 5. I have tried a lot but cannot find where am I making the mistake.
My approach-
I have used segment trees with lazy propagation.
For each query of type 1, I will update my segment tree nodes with the sum of fibonaci numbers added corresponding to the nodes of the tree.
Then for finding answer to query [L-R], I have to just find the sum of values of the corresponding nodes from the tree and add sum of original array values in [L-R].
I was using the property that if one knows first two fibonacci numbers then one can find n th fibonaci number and also sum of first n fibonacci numbers. code link.
Any help given in this regard will be highly appreciated.
Edit: I am also not able to understand the editorial that how does a2=b2 mod M => a=b mod M. So please help me by sharing your opinions and approaches.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English gi_sha 2018-08-06 20:20:54 184 Tiny change: 'preciated.\n**Edit**' -> 'preciated.<br>\n**Edit**'
en3 English gi_sha 2018-08-06 14:16:48 42
en2 English gi_sha 2018-08-06 09:47:26 56
en1 English gi_sha 2018-08-05 21:36:44 925 Initial revision (published)