#P7493. [传智杯 #3 决赛] 旅人1969
[传智杯 #3 决赛] 旅人1969
Background
In the 21st century, which is called the future, only unease and a little fantasy remain.
O sinners of eternity and instant, the Noah's Ark of the 20th century carries expectations and unease and flies toward the sky!
And you, as hope, on this journey that is not eternal, how will you move forward?
Problem Description
On a straight road, there are hotels. The coordinate of the -th hotel is . Every morning, you start from a hotel and can walk a maximum distance of . You are also given a fixed constant .
You are given queries. In each query, given , find the number of plans to start in the morning from hotel to hotel , passing through at most hotels (excluding the start point ) and keeping the walking direction unchanged. Two plans are different if and only if there exists a different choice of a hotel. The answer should be taken modulo .
For all testdata, , , , and .
Input Format
The input has lines.
The first line contains positive integers .
The next lines each contain positive integers , representing a query.
Output Format
Output lines, each containing integer, representing the answer.
3 2 2 2
1 3
2 3
2
1
2077 30 200 3
1949 2021
1969 2077
1970 2004
360658315
804081653
603979748
Hint
Translated by ChatGPT 5