Codeforces Round 830 (Div. 2) |
---|
Finished |
You are given two arrays of integers $$$a_1, a_2, \ldots, a_n$$$ and $$$b_1, b_2, \ldots, b_n$$$. You need to handle $$$q$$$ queries of the following two types:
In this problem $$$\gcd(x, y)$$$ denotes the greatest common divisor of $$$x$$$ and $$$y$$$, and $$$\operatorname{lcm}(x, y)$$$ denotes the least common multiple of $$$x$$$ and $$$y$$$.
The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \leq n, q \leq 5 \cdot 10^4$$$) — the number of numbers in the arrays $$$a$$$ and $$$b$$$ and the number of queries.
The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 5 \cdot 10^4$$$) — the elements of the array $$$a$$$.
The third line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$1 \leq b_i \leq 5 \cdot 10^4$$$) — the elements of the array $$$b$$$.
Then $$$q$$$ lines follow, $$$j$$$-th of which starts with an integer $$$t_j$$$ ($$$1 \leq t_j \leq 2$$$) and means that the $$$j$$$-th query has type $$$t_j$$$.
If $$$t_j = 1$$$, it is followed by three integers $$$l_j$$$, $$$r_j$$$, and $$$x_j$$$ ($$$1 \leq l_j \leq r_j \leq n$$$, $$$1 \leq x_j \leq 5 \cdot 10^4$$$).
If $$$t_j = 2$$$, it is followed by two integers $$$l_j$$$ and $$$r_j$$$ ($$$1 \leq l_j \leq r_j \leq n$$$).
It is guaranteed that there is at least one query of type $$$2$$$.
For each query of the second type, output the minimum value of the expression.
10 106 10 15 4 9 25 2 3 5 301 2 3 4 6 9 12 15 18 302 1 101 7 10 92 5 101 1 6 142 4 72 3 91 2 9 302 1 42 3 72 5 10
1 2 12 2 10 5 2
4 410 2 12 51 12 16 12 2 41 2 3 181 2 2 102 2 3
5 30
In the first example:
In the second:
Name |
---|