#P3228. [HNOI2013] 数列
[HNOI2013] 数列
Description
Xiao T is learning to buy stocks. He got insider information: the stock of company F will soar. The price each day is a positive integer, and due to objective reasons, it can be at most . During the days of soaring, Xiao T observed that: except for the first day, each day's price is higher than the previous day, and the increase (i.e., today's price minus yesterday's price) does not exceed , where is a positive integer. Moreover, these parameters satisfy . Xiao T forgot the exact price on each of the days; he now wants to know how many possible price sequences there are for these days.
Input Format
Only one line with four space-separated numbers: , , , . For , see the explanation in the “Output Format” section below. It is guaranteed that for 20% of the testdata , and for 100% of the testdata , .
Output Format
Output a single number: the number of possible price sequences over days modulo .
7 3 2 997
16
Hint
Sample Explanation
The output sample’s means there are possible price sequences for the input sample:
, , , , , , , , , , , , , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号