Yarra Gnisrever (noch nicht übersetzt)
Let N and K be two positive integers.
Fn is the n-th Fibonacci number: F1=F2=1, Fn=Fn−1+Fn−2 for all n≥3.
Let sn=F2n−1modN and let tn=F2nmodN.
Start with an array of integers A=(A[0],⋯,A[N−1]) where initially every A[i] is equal to i. Now perform K successive operations on A, where the j-th operation consists of reversing the order of those elements in A with indices between sj and tj (both ends inclusive).
Define R(N,K) to be ∑N−1i=0i×A[i] after K operations.
For example, R(5,4)=27, as can be seen from the following procedure:
Initial position: (0,1,2,3,4)
Step 1 - Reverse A[1] to A[1]: (0,1,2,3,4)
Step 2 - Reverse A[2] to A[3]: (0,1,3,2,4)
Step 3 - Reverse A[0] to A[3]: (2,3,1,0,4)
Step 4 - Reverse A[3] to A[1]: (2,0,1,3,4)
R(5,4)=0×2+1×0+2×1+3×3+4×4=27
Also, R(102,102)=246597 and R(104,104)=249275481640.
Find R(1018,106) giving your answer modulo 109.