33OJ
登录 注册

#P13982. 数列分块入门 7

数列分块入门 7

Background

The constraint ranges of the test data of the Luogu Sequence Blocking Primer series differ from those of the original problems.

Problem Description

Given a sequence of length nn and nn operations, where the operations involve interval multiplication, interval addition, and single-point queries.

Input Format

The first line contains a number nn.

The second line contains nn numbers separated by spaces, where the ii-th number is aia_i.

Then nn queries follow, each on one line with four numbers opt\mathrm{opt}, ll, rr and cc separated by spaces.

If opt=0\mathrm{opt} = 0, it means adding cc to all numbers in [l,r][l, r].

If opt=1\mathrm{opt} = 1, it means multiplying all numbers in [l,r][l, r] by cc.

If opt=2\mathrm{opt} = 2, it means querying the value of ara_r mod10007\mathop{\mathrm{mod}} 10007 (ll and cc are ignored). You need to output a non-negative remainder.

Output Format

For each query, output one line with a single number, the answer.

7
1 2 2 3 9 3 2
0 1 3 1
2 1 3 1
1 1 4 4
0 1 7 2
1 2 6 4
1 1 6 5
2 2 6 4
3
100

Hint

Subtasks

Subtask 1 (4040 points): 1≤n≤1000001 \leq n \leq 100000, −231≤ai,c≤231−1-2^{31} \leq a_i, c\leq 2^{31}-1.

Subtask 2 (6060 points): 1≤n≤3000001 \leq n \leq 300000, −231≤ai,c≤231−1-2^{31} \leq a_i, c\leq 2^{31}-1.

For all test data, 1≤n≤3000001 \leq n \leq 300000, −231≤ai,c≤231−1-2^{31} \leq a_i, c\leq 2^{31}-1, opt∈{0,1,2}\mathrm{opt} \in \{0,1,2\} and 1≤l≤r≤n1 \leq l \leq r \leq n.

Translated by QwenWork