luogu#P3987. 我永远喜欢珂朵莉~
我永远喜欢珂朵莉~
Background
Can't quit the Chtholly addiction.
Sqrt decomposition that I just can't pull off.



Oh, by the way, are there any "Ke-ologists" who want to buy the BD? Please support Moyu~.
Or does anyone want to join a figure crowdfunding?
Problem Description
Give Chtholly a non-negative sequence of length , supporting the following two operations:
- : Divide all multiples of in the interval by .
- : Query the sum of elements in the interval .
Chtholly is very cute, so you should help her solve this problem.
Input Format
The first line contains two numbers .
The second line contains non-negative integers .
Then there are lines, each describing one operation:
- : Divide all multiples of in the interval by .
- : Query the sum of elements in the interval .
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
, , .
Translated by ChatGPT 5