Yarra Gnisrever (noch nicht übersetzt)

Problem 680

Let N and K be two positive integers.

Fn is the n-th Fibonacci number: F1=F2=1, Fn=Fn1+Fn2 for all n3.
Let sn=F2n1modN and let tn=F2nmodN.

Start with an array of integers A=(A[0],,A[N1]) 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 N1i=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.