#P4108. [HEOI2015] 公约数数列
[HEOI2015] 公约数数列
Description
Design a data structure. Given a sequence of positive integers , you need to support the following two operations:
- : set to .
- : find the smallest integer () such that $\gcd(a_0, a_1, \cdots, a_p) \times \operatorname{xor}(a_0, a_1, \cdots, a_p) = x$. Here denotes the xor-sum of , and denotes the greatest common divisor.
Input Format
The first line contains a positive integer . The next line contains positive integers . The next line contains a positive integer , the number of queries. Each of the next lines contains one query, in the format described above.
Output Format
For each , output the result on a separate line. If no such exists, output no.
10
1353600 5821200 10752000 1670400 3729600 6844320 12544000 117600 59400 640
10
MODIFY 7 20321280
QUERY 162343680
QUERY 1832232960000
MODIFY 0 92160
QUERY 1234567
QUERY 3989856000
QUERY 833018560
MODIFY 3 8600
MODIFY 5 5306112
QUERY 148900352
6
0
no
2
8
8
Hint
Constraints
- For 30% of the testdata, , .
- For 100% of the testdata, , , , in operations , in modify operations , .
Translated by ChatGPT 5
京公网安备 11011102002149号