0%

Problem 680


Problem 680


Yarra Gnisrever

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 i=0N1i×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.


组数转逆

任取两个正整数NK

Fn是第n个斐波那契数:F1=F2=1,对于所有n3Fn=Fn1+Fn2
sn=F2n1modNtn=F2nmodN

在初始状态下,整数数组A=(A[0],,A[N1])中,A[i]等于i。现在,对A进行连续的K次逆转操作,其中第j次操作将数组A中下标在sjtj之间(包含两端)的元素逆序排列。

完成K次操作后,记R(N,K)i=0N1i×A[i]

例如,R(5,4)=27,其操作和计算过程如下所示:

初始状态:(0,1,2,3,4)
1步 - 将A[1]A[1]逆转:(0,1,2,3,4)
2步 - 将A[2]A[3]逆转:(0,1,3,2,4)
3步 - 将A[0]A[3]逆转:(2,3,1,0,4)
4步 - 将A[3]A[1]逆转:(2,0,1,3,4)
R(5,4)=0×2+1×0+2×1+3×3+4×4=27

已知,R(102,102)=246597R(104,104)=249275481640

R(1018,106)并将你的答案对109取余。


Gitalking ...