luogu#P10256. 高仿的 Migos
高仿的 Migos
Problem Description
After hard training, ZHY finally became a rapper. But one day, rapper ZHY saw works by the peer rap group Migos, and immediately realized the gap between them. So he wants to learn Migos' rap skills and reproduce Migos' success.
After researching for several days and nights, ZHY finally selected rap works of Migos, numbered in order. He believes that as long as he finishes learning these works, he can become a better rapper. Therefore, he will start from work , and learn them one by one in increasing order. After finishing work , he ends his learning.
However, rapper ZHY has a very special way of learning. For each work, he only listens for minute. The problem with this learning method is that for work , after spending minute, he may succeed or fail. Specifically, if ZHY is learning work , then after he spends one minute learning:
- With probability , ZHY succeeds, and then he will continue to learn work (of course, if , he ends the learning directly).
- With probability , ZHY fails. Unfortunately, the memory in his brain will become confused, causing him to remember only the first works, i.e. he must restart learning from work .
After trying to learn several times, ZHY was deeply troubled by the memory confusion, so he asked brain science expert YHZ for help. After YHZ's research, he found that all follow a certain pattern. Specifically, he found pairs of natural numbers , where , satisfying . Then $x_i=\max\limits_{j=1}^m\{l_j \mid l_j+1\leq i\leq r_j\}$. In particular, if for all , it is not true that , then .
Now ZHY has fully understood his learning ability, but the previous attempts made him exhausted, so he decided to rest for second, and hopes you can help him compute the expected number of minutes he needs to finish learning. However, he realized that learning each work for a fixed minute is not comprehensive enough, so he decided to change the one minute he spends on some works, which will change the success probability of learning that work. Specifically, ZHY now提出 (pinyin: tichu) requests, and each request is one of the following two types:
- Modify the success probability of some work .
- Query the expected number of minutes needed to finish learning all works under the current probabilities.
Since ZHY needs to rest, he turned to you and hopes you can handle his requests. For each request of the second type, you should output the expected time modulo . ZHY gave you second, because he can only rest for that long.
Input Format
The first line contains three integers , with the meaning as described above.
In the next lines, each line contains two positive integers , meaning .
In the next lines, each line contains two integers .
In the next lines, each line is in one of the following two formats:
1 x a bis a modification operation, meaning becomes . It is guaranteed that , , and are all positive integers.2is a query operation, meaning to ask what the expected time to finish learning is at this moment, modulo .
Output Format
For each query, output one integer per line representing the answer.
3 1 3
1 3
2 3
1 4
2 3
2
1 2 4 5
2
10
9
2 1 1
1 1
1 2
0 2
2
4
2 1 1
1 1
1 2
1 2
2
3
Hint
This problem uses bundled testdata.
| Subtask ID | Special Property | Score | |||
|---|---|---|---|---|---|
| None | |||||
| B | |||||
| None | |||||
| A | |||||
| B | |||||
| C | |||||
| None | |||||
All “intervals” below refer to .
Special Property A: It is guaranteed that for all , .
Special Property B: It is guaranteed that the intersections of these intervals are all . That is, for all with , we have or .
Special Property C: It is guaranteed that these intervals have no containment relationship. That is, for all with , we have or .
For of the data, , , , .
Translated by ChatGPT 5