#P7493. [传智杯 #3 决赛] 旅人1969
[传智杯 #3 决赛] 旅人1969
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
京公网安备 11011102002149号