Reziba has many magic gems. Each magic gem can be split into MM normal gems. The amount of space each magic (and normal) gem takes is 11 unit. A normal gem cannot be split.
Reziba wants to choose a set of magic gems and split some of them, so the total space occupied by the resulting set of gems is NN units. If a magic gem is chosen and split, it takes MM units of space (since it is split into MM gems); if a magic gem is not split, it takes 11 unit.
How many different configurations of the resulting set of gems can Reziba have, such that the total amount of space taken is NN units? Print the answer modulo 10000000071000000007 (109+7109+7). Two configurations are considered different if the number of magic gems Reziba takes to form them differs, or the indices of gems Reziba has to split differ.
Input
The input contains a single line consisting of 22 integers NN and MM (1≤N≤10181≤N≤1018, 2≤M≤1002≤M≤100).
Output
Print one integer, the total number of configurations of the resulting set of gems, given that the total amount of space taken is NN units. Print the answer modulo 10000000071000000007 (109+7109+7).
Examples
input
Copy
4 2
output
Copy
5
input
Copy
3 2
output
Copy
3
In the first example each magic gem can split into 22 normal gems, and we know that the total amount of gems are 44.
Let 11 denote a magic gem, and 00 denote a normal gem.
The total configurations you can have is:
11111111 (None of the gems split);
00110011 (First magic gem splits into 22 normal gems);
10011001 (Second magic gem splits into 22 normal gems);
11001100 (Third magic gem splits into 22 normal gems);
00000000 (First and second magic gems split into total 44 normal gems).
Hence, answer is 55.
题解:
考虑 dpdp , f[i]f[i] 表示用 ii 个单位空间的方案数,答案即为 f[n]f[n].
对于一个位置,我们可以放 MagicMagic 的,占 mm 空间,也可以放 NormalNormal 的,占 11 空间.