#P3987. 我永远喜欢珂朵莉~

    ID: 2917 远端评测题 4000ms 1250MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>平衡树树状数组深度优先搜索,DFS洛谷月赛

我永远喜欢珂朵莉~

Description

Give Chtholly a non-negative sequence aa of length nn, supporting the following two operations:

  • 1 l r x\verb!1 l r x!: Divide all multiples of xx in the interval [l,r][l,r] by xx.
  • 2 l r\verb!2 l r!: Query the sum of elements in the interval [l,r][l,r].

Chtholly is very cute, so you should help her solve this problem.

Input Format

The first line contains two numbers n,mn,m.

The second line contains nn non-negative integers aia_i.

Then there are mm lines, each describing one operation:

  • 1 l r x\verb!1 l r x!: Divide all multiples of xx in the interval [l,r][l,r] by xx.
  • 2 l r\verb!2 l r!: Query the sum of elements in the interval [l,r][l,r].

Output Format

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

5 3
1 2 3 4 5
2 1 5
1 1 5 2
2 1 5
15
12

Hint

Constraints

1n,m1051 \le n , m \le 10^5, 0ai5×1050 \le a_i \le 5\times 10^5, 1x5×1051 \le x \le 5\times 10^5.

Translated by ChatGPT 5