#P8768. [蓝桥杯 2021 国 A] 积木
[蓝桥杯 2021 国 A] 积木
Problem Description
Xiao Lan has a large number of cubic blocks (all blocks are exactly the same). He plans to use them to build a huge shape.
To make it more stable, Xiao Lan lays all the blocks flat on the ground instead of stacking them. He arranges the blocks row by row, with all rows left-aligned. There are a total of rows, forming the final shape.
In the first row, Xiao Lan places blocks. Starting from the second row, the number of blocks in row is at least more than the previous row, and at most more than the previous row (when , it means it can be the same as the previous row), i.e.
Given , , and , among all plans that satisfy the conditions above, how many plans also satisfy that the number of blocks in row is exactly times the number of blocks in row .
Input Format
One line contains integers , with meanings as described above.
Output Format
Output one integer, representing the number of valid plans. The answer may be very large; output the remainder of the answer modulo .
5 1 1 2 2 5 3
4
233 5 1 8 100 215 3
308810105
Hint
Sample Explanation
The blocks that meet the conditions are shown in the figure below.

Testdata Scale and Constraints
For of the testdata, $1 \leq n \leq 10, 1 \leq w \leq 10, 0 \leq L \leq R \leq 3$.
For of the testdata, $1 \leq n \leq 20, 1 \leq w \leq 10, 0 \leq L \leq R \leq 4$.
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, .
For all testdata, $1 \leq n \leq 5\times10^5, 0 \leq w \leq 10^{9}, 0 \leq L \leq R \leq 40$, .
Lanqiao Cup 2021 National Contest A Group, Problem J.
Translated by ChatGPT 5