#P4900. Flowers
Flowers
Flowers
题面翻译
给定正整数 。称一个 字符串是好的当且仅当其可以通过把连续 个 全部改成 来达到全为 ,例如 时,000
,0110
,110110
是好的而 010
,101
不是好的。
多次询问,每次给定 ,询问长度在 内的 字符串有多少个是好的。由于结果可能过大,答案对 取模。
题目描述
We saw the little game Marmot made for Mole's lunch. Now it's Marmot's dinner time and, as we all know, Marmot eats flowers. At every dinner he eats some red and white flowers. Therefore a dinner can be represented as a sequence of several flowers, some of them white and some of them red.
But, for a dinner to be tasty, there is a rule: Marmot wants to eat white flowers only in groups of size .
Now Marmot wonders in how many ways he can eat between and flowers. As the number of ways could be very large, print it modulo ( ).
输入格式
We saw the little game Marmot made for Mole's lunch. Now it's Marmot's dinner time and, as we all know, Marmot eats flowers. At every dinner he eats some red and white flowers. Therefore a dinner can be represented as a sequence of several flowers, some of them white and some of them red.
But, for a dinner to be tasty, there is a rule: Marmot wants to eat white flowers only in groups of size .
Now Marmot wonders in how many ways he can eat between and flowers. As the number of ways could be very large, print it modulo ( ).
输出格式
We saw the little game Marmot made for Mole's lunch. Now it's Marmot's dinner time and, as we all know, Marmot eats flowers. At every dinner he eats some red and white flowers. Therefore a dinner can be represented as a sequence of several flowers, some of them white and some of them red.
But, for a dinner to be tasty, there is a rule: Marmot wants to eat white flowers only in groups of size .
Now Marmot wonders in how many ways he can eat between and flowers. As the number of ways could be very large, print it modulo ( ).
样例 #1
样例输入 #1
3 2
1 3
2 3
4 4
样例输出 #1
6
5
5
提示
- For = and length Marmot can eat ( ).
- For = and length Marmot can eat ( ) and ( ).
- For = and length Marmot can eat ( ), ( ) and ( ).
- For = and length Marmot can eat, for example, ( ) or ( ), but for example he can't eat ( ).