#P8768. [蓝桥杯 2021 国 A] 积木

    ID: 9686 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>2021多项式组合数学快速数论变换 NTT蓝桥杯国赛

[蓝桥杯 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 nn rows, forming the final shape.

In the first row, Xiao Lan places H1=wH_{1}=w blocks. Starting from the second row, the number of blocks HiH_{i} in row ii is at least LL more than the previous row, and at most RR more than the previous row (when L=0L=0, it means it can be the same as the previous row), i.e.

Hi1+LHiHi1+RH_{i-1}+L \leq H_{i} \leq H_{i-1}+R_{\circ}

Given xx, yy, and zz, among all plans that satisfy the conditions above, how many plans also satisfy that the number of blocks in row yy is exactly zz times the number of blocks in row xx.

Input Format

One line contains 77 integers n,w,L,R,x,y,zn, w, L, R, x, y, z, 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 998244353998244353.

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 10%10 \% of the testdata, $1 \leq n \leq 10, 1 \leq w \leq 10, 0 \leq L \leq R \leq 3$.

For 20%20 \% of the testdata, $1 \leq n \leq 20, 1 \leq w \leq 10, 0 \leq L \leq R \leq 4$.

For 35%35 \% of the testdata, 1n500,0LR101 \leq n \leq 500, 0 \leq L \leq R \leq 10.

For 50%50 \% of the testdata, 1n5000,0LR101 \leq n \leq 5000, 0 \leq L \leq R \leq 10.

For 60%60 \% of the testdata, 1n20000,0LR101 \leq n \leq 20000, 0 \leq L \leq R \leq 10.

For 70%70 \% of the testdata, 1n50000,0LR101 \leq n \leq 50000, 0 \leq L \leq R \leq 10.

For 85%85 \% of the testdata, 1n3×105,0LR101 \leq n \leq 3\times10^5, 0 \leq L \leq R \leq 10.

For all testdata, $1 \leq n \leq 5\times10^5, 0 \leq w \leq 10^{9}, 0 \leq L \leq R \leq 40$, 1x<yn,0z1091 \leq x<y \leq n, 0 \leq z \leq 10^{9}.

Lanqiao Cup 2021 National Contest A Group, Problem J.

Translated by ChatGPT 5