Fibo siêu cấp

View as PDF

Submit solution

Points: 100.00 (partial)
Time limit: 2.0s
Memory limit: 256M
Input: stdin
Output: stdout

Authors:
Problem source:
lamle's kitchen
Problem type

Định nghĩa số fibo cấp x bằng công thức sau:

Fx,0,Fx,1,...,Fx,x1=1.

Fx,i=j=i(x(imodx))i1Fx,j.

Cho 2 số nx, bạn cần tìm Fx,n là số fibo cấp x thứ n modulo 109+7.

Input

  • Nhập 2 số nguyên dương nx (n1018,x100).

Output

  • In ra Fx,n modulo 109+7.

Sample Input 1

Copy
10 3

Sample Output 1

Copy
56

Sample Input 2

Copy
420 69

Sample Output 2

Copy
464694677

Note

Khi x=3, 11 số đầu của dãy fibo cấp 31,1,1,3,4,4,11,15,15,41,56.

Constraint

Subtask Điểm Giới hạn
1 20% n106
2 20% x=2
3 60% Không ràng buộc gì thêm

Comments

Please read the guidelines before commenting.


There are no comments at the moment.