2 shunfurh shunfurh 于 2017.04.21 20:29 提问

01-K Code

Consider a code string S of N symbols, each symbol can only be 0 or 1. In any consecutive substring of S, the number of 0's differs from the number of 1's by at most K. How many such valid code strings S are there?

For example, when N is 4, and K is 3, there are two invalid codes: 0000 and 1111.

Input

The input consists of several test cases. For each case, there are two positive integers N and K in a line.

N is in the range of [1, 62].

K is in the range of [2, 5].

Output

Output the number of valid code strings in a line for each case.

Sample Input

1 2
4 3
Sample Output

2
14

1个回答

caozhy
caozhy   Ds   Rxr 2017.05.05 23:53
已采纳
Csdn user default icon
上传中...
上传图片
插入图片