luogu#P10863. [HBCPC2024] Enchanted
[HBCPC2024] Enchanted
题目描述
In Minecraft, one way to become stronger is to have the armors and weapons enchanted. Enchanted books play an important role.
The most important attribute of an enchanted book is its level. The higher the level is, the better the book is. We could merge two books with the same level into one new book(the older two will disappear). The level of the new book is and the merger costs .
Now, Steve has enchanted books numbered from to . Initially, the -th book's level is . Steve asks you to help him with the following four operations.
-
Given two integers , calculate the maximum level Steve can reach by merging books numbered from to .
-
Given three integers and , then follow the steps:
Step : Steve merges all the books numbered from to until there does not exist two books with the same level.
Step : Steve adds one new book with level to the books he gets in Step .
Step : Steve needs to merge books he gets in Step and he wants to maximize the times he merges the books.
Please calculate and output the total cost modulo in Step .
$\textbf{Note that, after calculating, the sequence is restored. That is, this operation does NOT actually change the sequence.}$ -
Given two integers , Steve changes the level of the book numbered to .
-
Given one integer , Steve restores the sequence to the state after the -th operation. If , then Steve restores the sequence to the beginning state.
输入格式
The first and the only line contains 5 integers .(, , , , )
Please pay attention! To avoid large input file, the true input is constructed through the following strategy:
$\textbf{Function rnd():}\ \ \ \\ A \leftarrow (7A+13) \bmod 19\,260\,817\ \ \ \\ \textbf{return } A$
Firstly, integers are generated in turn, .
Then, the parameters of all operations are generated.
For each operation, the number of operation(representing by ) is firstly generated, .
According to the number of operation, the different method is applied to generate parameters for different operation.
-
For operation 1: we need to get and by using:
-
For operation 2: we need to get and by using:
-
For operation 3: we need to get and by using:
-
For operation 4: we need to get by using:
Here, represents the -th operation.
输出格式
For each operation 1 and 2, you need to output one single line with an integer, representing the answer to operation 1 and 2 modulo .
6 3 2 1 3
1
3
2
10 15 5 4 7
0
9
9
0
64
0
0
提示
Function max
means the maximum one between the parameters. Function min
means the minimum one between the parameters.
In example 1, the initial books are . The three operations' ranges are , and .