Can someone tell where is my code wrong?

https://www.codechef.com/viewsolution/34926973

@ssrivastava990

You are only appending 5 integers to your array. You cannot say where the pattern will start to repeat from. The list can be of the form:

4324 5 8 3 7 2 9 8 6 1 4 | 2 9 8 6 1 4 | 2 9 8 6 1 4 | ...

(that’s the way I see it, if you think this is wrong please let me know the logic you used).

This is my submission. I store everything in an array A. And I store the index from which repetition starts in repi. After that answering queries is just simple math.