Fences painting - MarisaOJ: Marisa Online Judge

Fences painting

Time limit: 500 ms
Memory limit: 256 MB
Marisa's wooden fence is made up of $n$ planks. Marisa wants to repaint the fence using two colors: orange and yellow. The dominant color of the fence will be yellow with a little bit of orange. Therefore, Marisa wants any two orange planks to be at least $k$ planks apart. The distance between two planks at positions $i$ and $j$ is $|i-j|$. How many ways are there to paint the fence such that this condition is satisfied? ### Input - A single line containing two integers $n$ and $k$. ### Output - Output a single integer representing the number of ways to paint the fence, modulo $10^9 + 7$. ### Constraints - $1 \le n \le 2 \times 10^5$ - $1 \le k \le n$ ### Example Input: ``` 4 2 ``` Output: ``` 8 ``` There are $8$ ways, with letter `y` denoting yellow and letter `o` denoting orange: - `oyyy` - `yoyy` - `yyoy` - `oyoy` - `oyyo` - `yoyo` - `yyyo` - `yyyy`