Xâu nhị phân

View as PDF

Points: 400 (p) Time limit: 1.0s Memory limit: 256M Input: stdin Output: stdout

Cho 2 số \(n\)\(k\) ( \(2\le k \le n \le 10^6\))

Hãy đếm xem có bao nhiêu xâu nhị phân độ dài \(n\) mà không có quá \(k\) số 0 hoặc \(k\) số 1 nào liên tiếp nhau.

Input

  • Gồm 1 dòng duy nhất là 2 số \(n\)\(k\).

Output

  • Gồm 1 dòng duy nhất là số dãy nhị phân thoả mãn (\(module\ 10^9\)).

Example

Test 1

Input
3 2 
Output
6

Comments

There are no comments at the moment.