#P4256. 公主の#19准备月考
公主の#19准备月考
Description
The princess is very weak in liberal arts comprehensive, ranking in the whole school (and the whole school has just over students). After thinking for a long time, she found that if she puts all her time into multiple-choice questions, she can score a bit better.
There are questions in liberal arts, numbered from to .
The princess computed an estimated value for each question. She believes that the answer for a contiguous block of questions will lie between the and of their estimated values. Sometimes her thoughts change, and some questions’ estimated values will change. Sometimes multiple-answer questions appear; the number of correct answers for such questions equals the number of common divisors of the estimated values over a contiguous block.
Specifically, for a sequence, there are four operations:
L x y p: Ask for the value of of numbers in the range modulo .G x y p: Ask for the value of of numbers in the range modulo .C x y c: Change all numbers in the range to .S x y p: Ask for the number of common divisors of the numbers in the range , then take it modulo .
The princess must not fail the monthly exam, or she won't be able to study OI (just kidding), so please help her!
Input Format
The first line contains two positive integers and , where is the number of questions and is the number of operations.
The second line contains positive integers, representing the princess’s estimated values for the questions.
The next lines each contain one operation; see the Description for the format.
Output Format
For each query, output its answer.
10 10
42 68 35 1 70 25 79 59 63 65
L 2 6 28
L 2 6 43
G 2 7 5
G 3 4 83
L 7 9 96
G 2 7 39
S 3 8 100
L 4 5 12
G 4 4 65
L 2 4 69
0
32
1
1
75
1
1
10
1
34
Hint
Constraints
- For of the testdata, .
- For another of the testdata, , .
- For another of the testdata, , , and there are no update operations.
- For of the testdata, , .
At any time, each question’s estimated value is in , and each answer after taking modulo fits in int.
Translated by ChatGPT 5
京公网安备 11011102002149号