#SGM0000015. Bash và bài toán GCD khó (Bash and a Tough Math Puzzle)
Bash và bài toán GCD khó (Bash and a Tough Math Puzzle)
Bash and a Tough Math Puzzle
Source: Codeforces
Version: Phuoc Hung OJ Extended
Given an array , process two query types:
1 l r x: determine whether changing at most one element of could make the gcd of the segment equal to . This hypothetical change does not modify the stored array.2 i y: actually assign .
For each type 1 query, print YES if the guess is almost correct and NO otherwise.
Input
The first line contains .
The second line contains .
The third line contains .
The next lines describe the queries.
Output
For each type 1 query, print YES or NO.
Subtasks
- Subtask 1 — 20%: , .
- Subtask 2 — 30%: , .
- Subtask 3 — 50%: , , .
Examples
Input
3
2 6 3
4
1 1 2 2
1 1 3 3
2 1 9
1 1 3 2
Output
YES
YES
NO
Explanation
The sample follows the operations exactly; each printed line corresponds to a query that requires output.