#5116. Two Sequence Queries
Two Sequence Queries
Two Sequence Queries
题目描述
You are given sequences of length , and .
You are also given queries to process in order.
There are three types of queries:
: Add to each of . : Add to each of . : Print the remainder of when divided by .
输入格式
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:
输出格式
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.
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
16
25
84
2 3
1000000000 1000000000
1000000000 1000000000
3 1 1
1 2 2 1000000000
3 1 2
716070898
151723988
提示
All input values are integers. There is at least one query of the third type.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.
Make sure to print the sum modulo for the third type of query.
标签: AtCoder|abc357F
来源
AtCoder|abc357F