#QHD0000026. Hoa đỏ và hoa trắng (Flowers)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Hoa đỏ và hoa trắng (Flowers)
Flowers
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
A gardener arranges red and white flowers in a row. A red flower can be placed individually, while white flowers are placed in groups of exactly consecutive white flowers. Each such group acts as one unit during construction.
Count all arrangements whose total number of flowers is between and , inclusive. Arrangements are distinct when their color sequences differ.
Print the count modulo .
Input
One line contains three integers , , and : the white-block size and the inclusive length bounds.
Output
Print the number of valid flower arrangements of lengths through , modulo .
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; ; .
Examples
Input
2 1 3
Output
6
Explanation
For , a red flower is one unit and white flowers occur in blocks of two. Length has R; length has RR, WW; length has RRR, RWW, WWR. The total is .