#abc357f. F - Two Sequence Queries
F - Two Sequence Queries
Score : points
问题陈述
你得到了两个长度为 的序列, 和 。 你还需要按顺序处理 个查询。
有三种类型的查询:
1 l r x
: 将 加到 的每一个元素上。2 l r x
: 将 加到 的每一个元素上。3 l r
: 打印 除以 后的余数。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given sequences of length , and .
You are also given queries to process in order.
There are three types of queries:
1 l r x
: Add to each of .2 l r x
: Add to each of .3 l r
: Print the remainder of when divided by .
Constraints
- All input values are integers.
- There is at least one query of the third type.
Input
The input is given from Standard Input in the following format. Here, is the -th query to be processed.
Each query is given in one of the following formats:
Output
If there are queries of the third type, print lines.
The -th line () should contain the output for the -th query of the third type.
Sample Input 1
5 6
1 3 5 6 8
3 1 2 1 2
3 1 3
1 2 5 3
3 1 3
1 1 3 1
2 5 5 2
3 1 5
Sample Output 1
16
25
84
Initially, and . The queries are processed in the following order:
- For the first query, print modulo , which is .
- For the second query, add to . Now .
- For the third query, print modulo , which is .
- For the fourth query, add to . Now .
- For the fifth query, add to . Now .
- For the sixth query, print $(2\times 3)+(7\times 1)+(9\times 2)+(9\times 1)+(11\times 4)=84$ modulo , which is .
Thus, the first, second, and third lines should contain , , and , respectively.
Sample Input 2
2 3
1000000000 1000000000
1000000000 1000000000
3 1 1
1 2 2 1000000000
3 1 2
Sample Output 2
716070898
151723988
Make sure to print the sum modulo for the third type of query.