RECURSION LOVE - Solution? CodeFusion

Any help with this question: https://www.codechef.com/COFN2019/problems/CFD020/

First store all the cycles then apply prefixsum on each cycle.

1 Like

Divide the number of iterations by length of the cycle and multiply it with total sum of that cycle. After that you can calculate remaining sum by using prefixsum or any other method like segment tree.

1 Like