It is well known that Dong5k have so much money. Dong5k plan to have a journey from (0,0) to (n,0). He need to design a tourist route.
For each step, it is allowed to move only to go ahead (uphill, downhill or go straight) that means if Dong5k at point (x, y) in ith setp, he can go to one of the following point (x + 1, y + 1), (x + 1, y - 1), (x + 1, y) in (i + 1)-th step.
Dong5k is so famous not only his wealth but his weight. Uphill and downhill demands great physical strength. So he can't choose more than one uphill or downhill in the continuous k steps, that means if he uphill (or downhill) in ith step, next time he uphill (or downhill) at least in (i + k)-th step.
Calculate the number of different ways Dong5k can design.
Note: Dong5k can't under the ground, that means the y-coordinate must be equal or greater than 0 in each step.
2 3 1 3 2
4 2
In the first sample, there are four ways from (0, 0) to (3, 0): 1. (0, 0) -> (1, 0) -> (2, 0) -> (3, 0) 2. (0, 0) -> (1, 0) -> (2, 1) -> (3, 0) 3. (0, 0) -> (1, 1) -> (2, 0) -> (3, 0) 4. (0, 0) -> (1, 1) -> (2, 1) -> (3, 0) In the second sample, there are two ways from (0, 0) to (3, 0): 1. (0, 0) -> (1, 0) -> (2, 0) -> (3, 0) 2. (0, 0) -> (1, 1) -> (2, 1) -> (3, 0)
cxlove @AHU