#P5126. 鬼故事

鬼故事

Description

Given k,m,nk,m,n, find:

i=mnj=ii+k1aj\sum_{i=m}^n \prod_{j=i}^{i+k-1} a_j

Take the answer modulo 109+710^9 + 7.
Here {a}\{ a\} is the Fibonacci sequence.

Input Format

Three positive integers, representing k,m,nk,m,n respectively.

Output Format

Output one line with one integer, representing the answer.

4 1 3
276
3 2 3
36

Hint

a1=1,a2=1,a3=2,a4=3,a5=5,a6=8a_1=1,a_2=1,a_3=2,a_4=3,a_5=5,a_6=8.

For Sample 1:

K=4K=4 $$b_1=1\times1\times2\times3=6,b_2=1\times2\times3\times5=30,b_3=2\times3\times5\times8=240$$i=13bi=276\sum_{i=1}^{3}b_i=276

For Sample 2:

K=3K=3 b2=1×2×3=6,b3=2×3×5=30b_2=1\times2\times3=6,b_3=2\times3\times5=30 i=23bi=36\sum_{i=2}^{3}b_i=36

This problem has 2020 test points. Each test point is worth 55 points, for a total of 100100 points. The properties of each test point are as follows:

(The problem setter does not want to use 44 to represent any number anymore! so true)

ID Constraints on K,M,NK,M,N Special Property
11 1mn106,k=41\le m\le n\le 10^6,k=4 None
22 1mn1018,k=41\le m\le n\le 10^{18},k=4 nm106n-m\le 10^6
343\sim 4 None
565\sim 6 1mn444,k=41\le m\le n\le 4^{4^4},k=4 nm106n-m\le 10^6
7107\sim 10 1mn447,k=41\le m\le n\le 4^{4^7},k=4 None
111211\sim 12 1mn46000,2k101\le m\le n\le 4^{6000},2\le k\le 10
131413\sim 14 1mn1041,2k101\le m\le n\le 10^{41},2\le k\le 10
152015\sim 20 1mn1041,2k501\le m\le n\le 10^{41},2\le k\le 50

(Note: the Constraints described in the statement are only approximate. Please refer to the specific ranges above.)

abc=a(bc)a^{b^c}=a^{(b^c)}

Input Format

Three positive integers, representing k,m,nk,m,n respectively.

Output Format

Output one line with one integer, representing the answer.

Hint

a1=1,a2=1,a3=2,a4=3,a5=5,a6=8a_1=1,a_2=1,a_3=2,a_4=3,a_5=5,a_6=8

For Sample 1:

K=4K=4 $$b_1=1\times1\times2\times3=6,b_2=1\times2\times3\times5=30,b_3=2\times3\times5\times8=240$$i=13bi=276\sum_{i=1}^{3}b_i=276

For Sample 2:

K=3K=3 b2=1×2×3=6,b3=2×3×5=30b_2=1\times2\times3=6,b_3=2\times3\times5=30 i=23bi=36\sum_{i=2}^{3}b_i=36

This problem has 2020 test points. Each test point is worth 55 points, for a total of 100100 points. The properties of each test point are as follows:

(The problem setter does not want to use 44 to represent any number anymore! so true)

ID Constraints on K,M,NK,M,N Special Property
11 1mn106,k=41\le m\le n\le 10^6,k=4 None
22 1mn1018,k=41\le m\le n\le 10^{18},k=4 nm106n-m\le 10^6
343\sim 4 None
565\sim 6 1mn444,k=41\le m\le n\le 4^{4^4},k=4 nm106n-m\le 10^6
7107\sim 10 1mn447,k=41\le m\le n\le 4^{4^7},k=4 None
111211\sim 12 1mn46000,2k101\le m\le n\le 4^{6000},2\le k\le 10
131413\sim 14 1mn1041,2k101\le m\le n\le 10^{41},2\le k\le 10
152015\sim 20 1mn1041,2k501\le m\le n\le 10^{41},2\le k\le 50

(Note: the Constraints described in the statement are only approximate. Please refer to the specific ranges above.)

abc=a(bc)a^{b^c}=a^{(b^c)}

Translated by ChatGPT 5