#P3824. [NOI2017] 泳池

    ID: 2781 远端评测题 1000~3000ms 125MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>递推2017NOI 系列O2优化线性递推,递推式向量

[NOI2017] 泳池

Description

After preliminary analysis, this sea area can be viewed as a rectangular grid with base length NN meters and height 10011001 meters. The base of the grid corresponds to her private beach, and each 1m×1m1\:\textrm{m} \times 1\:\textrm{m} small square represents one unit sea area. She will ask her father to measure tomorrow whether each small square is safe. After obtaining the information, all she needs to do is to fence out her desired swimming field.

Her ideal swimming field must satisfy the following three conditions:

  • Safety. Every unit sea area in the swimming field must be safe.
  • Rectangular. The swimming field must be an a×ba \times b subgrid of the whole grid.
  • Adjacent to the beach. The lower boundary of the swimming field must be flush with the bottom boundary of the grid.

For example: when N=5N = 5, suppose the measurement results are as follows (since 10011001 is too large, only the bottom three rows are shown here; the other parts are unsafe).

Then she can select the 1×41 \times 4 subregion in the bottom row, or the 3×13 \times 1 subregion in the third column. Note that she cannot select the 1×51 \times 5 subregion in the top row because it is not adjacent to the beach.

To maximize her friends’ fun, she wants the swimming field to have the largest possible area. Therefore she would choose the 1×41 \times 4 subregion in the bottom row as the final plan.

Although she will only know tomorrow whether each unit sea area is safe, she wants to estimate now how large the area of her swimming field might be. With a simple estimate, she assumes each unit sea area is independently safe with probability qq and unsafe with probability 1q1 - q. She wants to know the probability that the maximum area of a selectable swimming field is exactly KK.

However, Jiulian is not interested in mathematics, so she wants you to help her compute this value.

Input Format

The input contains one line with four positive integers N,K,x,yN, K, x, y, where 1x<y<9982443531 \leq x < y < 998\,244\,353. The value of qq is xy\dfrac{x}{y}.

Output Format

Output one integer: the value of the answer modulo 998244353998\,244\,353.

That is, write the answer as a reduced fraction ab\dfrac{a}{b} with gcd(a,b)=1\gcd(a, b) = 1. Output the integer xx such that bxamod998244353b x \equiv a \bmod 998\,244\,353 and 0x<9982443530 \leq x < 998\,244\,353. It can be proven that such an integer xx is unique.

10 5 1 2
342025319

Hint

Test point ID NN KK
1,2 =1= 1 1000\leq 1000
3 10\leq 10 8\leq 8
4 9\leq 9
5 10\leq 10
6 1000\leq 1000 7\leq 7
7 8\leq 8
8 9\leq 9
9,10,11 100\leq 100
12,13,14 1000\leq 1000
15,16 109\leq 10^9 10\leq 10
17,18 100\leq 100
19,20 1000\leq 1000

Translated by ChatGPT 5