#P13979. 数列分块入门 4
数列分块入门 4
Background
The constraints of the testdata in Luogu's "Introduction to Sequence Block Decomposition" series differ from those of the original problems.
Problem Description
You are given a sequence of length and operations. The operations involve range addition and range sum.
Input Format
The first line contains one integer .
The second line contains integers, where the -th integer is , separated by spaces.
Then lines follow, each containing a query. Each line contains four integers , , , , separated by spaces.
If , it means that is added to every number in .
If , it means that you should query the sum of all numbers in modulo . You need to output a non-negative remainder.
Output Format
For each query, output one integer on a single line giving the answer.
4
1 2 2 3
0 1 3 1
1 1 4 4
0 1 2 2
1 1 2 4
1
4
Hint
Subtasks
Subtask 1 (40 points): , .
Subtask 2 (60 points): , .
For all testdata, and . . , . After each operation every satisfies . In particular, the testdata guarantee that when .
Translated by QwenWork