#P3824. [NOI2017] 泳池
[NOI2017] 泳池
Description
After preliminary analysis, this sea area can be viewed as a rectangular grid with base length meters and height meters. The base of the grid corresponds to her private beach, and each 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 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 , suppose the measurement results are as follows (since is too large, only the bottom three rows are shown here; the other parts are unsafe).

Then she can select the subregion in the bottom row, or the subregion in the third column. Note that she cannot select the 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 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 and unsafe with probability . She wants to know the probability that the maximum area of a selectable swimming field is exactly .
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 , where . The value of is .
Output Format
Output one integer: the value of the answer modulo .
That is, write the answer as a reduced fraction with . Output the integer such that and . It can be proven that such an integer is unique.
10 5 1 2
342025319
Hint
| Test point ID | ||
|---|---|---|
| 1,2 | ||
| 3 | ||
| 4 | ||
| 5 | ||
| 6 | ||
| 7 | ||
| 8 | ||
| 9,10,11 | ||
| 12,13,14 | ||
| 15,16 | ||
| 17,18 | ||
| 19,20 |
Translated by ChatGPT 5
京公网安备 11011102002149号