atcoder#ABC256H. [ABC256Ex] I like Query Problem

[ABC256Ex] I like Query Problem

Score : 600600 points

Problem Statement

You are given NN, QQ, and A=(a1,,aN)A=(a_1,\ldots,a_N). Process QQ queries described below. Each query is of one of the following three kinds:

  • 1 L R x: for i=L,L+1,,Ri=L,L+1,\dots,R, update the value of aia_i to $\displaystyle \left\lfloor \frac{a_i}{x} \right\rfloor$.
  • 2 L R y: for i=L,L+1,,Ri=L,L+1,\dots,R, update the value of aia_i to yy.
  • 3 L R: print i=LRai\displaystyle\sum_{i=L}^R a_i.

Constraints

  • 1N5×1051 \leq N \leq 5 \times 10^5
  • 1Q1051 \leq Q \leq 10^5
  • 1LRN1 \leq L \leq R \leq N
  • 1ai1051 \leq a_i \leq 10^5
  • 2x1052 \leq x \leq 10^5
  • 1y1051 \leq y \leq 10^5
  • All values in input are integers.

Input

Input is given from Standard Input in the following format, where queryi\text{query}_i denotes the ii-th query to be processed:

NN QQ

a1a_1 a2a_2 \dots aNa_N

query1\text{query}_1

query2\text{query}_2

\vdots

queryQ\text{query}_Q

Each query is given in one of the following three formats:

11 LL RR xx

22 LL RR yy

33 LL RR

Output

Print the answer to the queries as specified in the Problem Statement, with newlines in between.

3 5
2 5 6
3 1 3
1 2 3 2
3 1 2
2 1 2 3
3 1 3
13
4
9

Initially, A=(2,5,6)A = (2, 5, 6). Thus, the answer to the 11-st query is a1+a2+a3=2+5+6=13a_1 + a_2 + a_3 = 2 + 5 + 6 = 13. When the 22-nd query has been processed, A=(2,2,3)A = (2, 2, 3). Thus, the answer to the 33-rd query is a1+a2=2+2=4a_1 + a_2 = 2 + 2 = 4. When the 44-th query has been processed, A=(3,3,3)A = (3, 3, 3). Thus, the answer to the 55-th query is a1+a2+a3=3+3+3=9a_1 + a_2 + a_3 = 3 + 3 + 3 = 9.

6 11
10 3 5 20 6 7
3 1 6
1 2 4 3
3 1 3
2 1 4 10
3 3 6
1 3 6 2
2 1 4 5
3 1 6
2 1 3 100
1 2 5 6
3 1 4
51
12
33
26
132