#6684. [ICPC 2025 Xi'an Practice] Zelda
[ICPC 2025 Xi'an Practice] Zelda
[ICPC 2025 Xi'an Practice] Zelda
题目描述
Zelda is given integers $l, r$ ($l \leq r$) and she has two sequences $a$ and $b$ of length $n$, indexed from $1$ to $n$. Zelda will use these two sequences to play a game, which proceeds as follows:- Uniformly and randomly select an integer from the interval .
- For , execute the following operations in order: first let , then let .
Zelda wants to know the expected value of the final .
Unfortunately, Zelda has forgotten some of the integers in sequences and , so she wants you to calculate the expected value of the final when all forgotten integers are also uniformly and randomly selected from the interval , modulo . Since Zelda will play the game multiple times, you need to answer queries for multiple different values of .
输入格式
The first line of the input contains three integers $n, q, l$ ($1 \leq n, l \leq 200$, $1 \leq q \leq 5 \times 10^4$), indicating the length of the two sequences, the number of times Zelda plays the game, and the lower bound for uniform random selections.The next line of the input contains non-negative integers ( or ). means the integer was forgotten by Zelda.
The next line of the input contains non-negative integers ( or ). means the integer was forgotten by Zelda.
The next line of the input contains integers (), indicating the value of each time Zelda plays a game.
输出格式
The output contains $q$ lines, where the $i$-th line contains a single integer representing the answer for the $i$-th game, modulo $10^9 + 7$.Formally, let . It can be shown that the answer can be expressed as an irreducible fraction , where and are integers and . Output the integer equal to . In other words, output such an integer that and .
2 5 1
2 2
0 1
1 2 3 50 538
1
750000007
888888897
857200008
228862927
3 5 2
3 3 0
3 0 0
2 3 4 50 519
2
750000008
962962973
798646858
311741862
提示
In the first example, sequences $a = [2, 2]$ and $b = [0, 1]$ (where $b_1 = 0$ indicates a forgotten value), and there are $q = 5$ queries.In the first query, , so always. The game process is as follows:
- Initially, .
- Do operations with , first, and then .
- Do operations with , first, and then .
So the answer for the first query is .
In the second query, , so should be selected from .
- , becomes after all operations.
- , becomes after all operations.
- , becomes after all operations.
- , becomes after all operations.
Each case has probability , so the answer for the second query is . 标签: P14446|2025|概率论|期望|ICPC|拉格朗日插值法|西安