Codeforces Round 230 (Div. 1)
C
Yet Another Number Sequence
Codeforces
未评级
原题
← BD →
翻译中…

Everyone knows what the Fibonacci sequence is. This sequence can be defined by the recurrence relation:

翻译中…

$*F*_{1} = 1, *F*_{2} = 2, *F*_{*i*} = *F*_{*i* - 1} + *F*_{*i* - 2} (*i* > 2).$

翻译中…

We'll define a new number sequence $*A*_{*i*}(*k*)$ by the formula:

翻译中…

$*A*_{*i*}(*k*) = *F*_{*i*} × *i*^{*k*} (*i* ≥ 1).$

翻译中…

In this problem, your task is to calculate the following sum: $*A*_{1}(*k*) + *A*_{2}(*k*) + ... + *A*_{*n*}(*k*)$. The answer can be very large, so print it modulo $1000000007$ $(10^{9} + 7)$.

翻译中…

Input

翻译中…

The first line contains two space-separated integers $*n*$, $*k*$ $(1 ≤ *n* ≤ 10^{17}; 1 ≤ *k* ≤ 40)$.

翻译中…

Output

翻译中…

Print a single integer — the sum of the first $*n*$ elements of the sequence $*A*_{*i*}(*k*)$ modulo $1000000007$ $(10^{9} + 7)$.

翻译中…

样例

Input #1
1 1
Output #1
1
InputCopy OutputCopy
Input #2
4 1
Output #2
34
InputCopy OutputCopy
Input #3
5 2
Output #3
316
InputCopy OutputCopy
Input #4
7 4
Output #4
73825
InputCopy OutputCopy
题目信息
题号
392C
时间限制
1 s
内存限制
256 MB
标签
组合数学
数学
矩阵

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。