Any help with this question: CodeChef: Practical coding for everyone
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