Блог пользователя gi_sha

Автор gi_sha, история, 6 лет назад, По-английски

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.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится