| ICPC Masters Mexico LATAM 2023 |
|---|
| Закончено |
Elisa's electric piano recently received an interesting upgrade. It now has an educational mode powered by artificial intelligence that allows users to learn how to play sequences of keyboard notes that form melodies. In this mode, all Elisa needs to do is press the key she wants to start playing with, and then the keyboard lights up the next key she should play. When Elisa plays that key, another key (or sometimes the same key) lights up, and the process continues until Elisa decides to stop. Elisa's keyboard has $$$N$$$ keys, numbered from $$$1$$$ to $$$N$$$. The melody generated by the training system is the sequence of keys that were played. For example, $$$1, 1, 1, 1$$$ is a melody where the key with the number 1 was played 4 times, and $$$1, 2, 3, 2, 1$$$ is a melody where those keys were played in that order.
Elisa's mother always watches her when she is playing and is fascinated by the melodies generated by this training mode. It sounds as if her daughter is a composer!. After observing Elisa play for a while, she has noticed that after playing a key, the next key is at most a distance $$$D$$$ away on the keyboard. For example, if Elisa has played the key with the number $$$1$$$ and $$$D=3$$$, the next key will be one of the following $$$7$$$ keys: $$$N-2, N-1, N, 1, 2, 3$$$, or $$$4$$$. Elisa's mother has decided to solve a mathematics problem based on this new keyboard function while Elisa has fun learning. She knows that she can calculate how many different melodies the keyboard can suggest to Elisa that have at most $$$K$$$ keys in the melody, starting from key $$$S$$$. Can you calculate it too?
The first and only line of input contains $$$4$$$ integer numbers separated by a space $$$N$$$ ($$$1 \leq N \leq 100$$$), $$$D$$$ ($$$0 \leq D \lt N $$$), $$$K$$$ ($$$1 \leq K \leq 10^9$$$), and $$$S$$$ ($$$1 \leq S \leq N$$$), representing the number of keys on the keyboard, the maximum distance at which a key should be to be the next in the sequence, the maximum number of keys in the melody, and the key where Elisa will start to play.
Print a line with a single integer number, the number of different melodies the electric piano can suggest. Because this number can be very large, output the remainder of dividing it by $$$10^9 + 7$$$.
3 1 1 2
1
3 1 2 2
4
4 1 3 3
13
| Название |
|---|


