CF1732E.Location

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given two arrays of integers a1,a2,,ana_1, a_2, \ldots, a_n and b1,b2,,bnb_1, b_2, \ldots, b_n . You need to handle qq queries of the following two types:

  • 11 ll rr xx : assign ai:=xa_i := x for all lirl \leq i \leq r ;
  • 22 ll rr : find the minimum value of the following expression among all lirl \leq i \leq r : $$$$\frac{\operatorname{lcm}(a_i, b_i)}{\gcd(a_i, b_i)}. $$

In this problem gcd(x,y)\\gcd(x, y) denotes the greatest common divisor of xx and yy , and operatornamelcm(x,y)\\operatorname{lcm}(x, y) denotes the least common multiple of xx and yy$$.

输入格式

The first line contains two integers nn and qq ( 1n,q51041 \leq n, q \leq 5 \cdot 10^4 ) — the number of numbers in the arrays aa and bb and the number of queries.

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n ( 1ai51041 \leq a_i \leq 5 \cdot 10^4 ) — the elements of the array aa .

The third line contains nn integers b1,b2,,bnb_1, b_2, \ldots, b_n ( 1bi51041 \leq b_i \leq 5 \cdot 10^4 ) — the elements of the array bb .

Then qq lines follow, jj -th of which starts with an integer tjt_j ( 1tj21 \leq t_j \leq 2 ) and means that the jj -th query has type tjt_j .

If tj=1t_j = 1 , it is followed by three integers ljl_j , rjr_j , and xjx_j ( 1ljrjn1 \leq l_j \leq r_j \leq n , 1xj51041 \leq x_j \leq 5 \cdot 10^4 ).

If tj=2t_j = 2 , it is followed by two integers ljl_j and rjr_j ( 1ljrjn1 \leq l_j \leq r_j \leq n ).

It is guaranteed that there is at least one query of type 22 .

输出格式

For each query of the second type, output the minimum value of the expression.

输入输出样例

  • 输入#1

    10 10
    6 10 15 4 9 25 2 3 5 30
    1 2 3 4 6 9 12 15 18 30
    2 1 10
    1 7 10 9
    2 5 10
    1 1 6 14
    2 4 7
    2 3 9
    1 2 9 30
    2 1 4
    2 3 7
    2 5 10

    输出#1

    1
    2
    12
    2
    10
    5
    2
  • 输入#2

    4 4
    10 2 12 5
    1 12 16 1
    2 2 4
    1 2 3 18
    1 2 2 10
    2 2 3

    输出#2

    5
    30

说明/提示

In the first example:

  • For the first query we can choose i=4i = 4 . So the value is lcm(4,4)gcd(4,4)=44=1\frac{\operatorname{lcm}(4, 4)}{\gcd(4, 4)} = \frac{4}{4} = 1 .
  • After the second query the array a=[6,10,15,4,9,25,9,9,9,9]a = [6, 10, 15, 4, 9, 25, 9, 9, 9, 9] .
  • For the third query we can choose i=9i = 9 . So the value is lcm(9,18)gcd(9,18)=189=2\frac{\operatorname{lcm}(9, 18)}{\gcd(9, 18)} = \frac{18}{9} = 2 .

In the second:

  • For the first query we can choose i=4i = 4 . So the value is lcm(1,5)gcd(1,5)=51=5\frac{\operatorname{lcm}(1, 5)}{\gcd(1, 5)} = \frac{5}{1} = 5 .
  • After the second query the array a=[10,18,18,5]a = [10, 18, 18, 5] .
  • After the third query the array a=[10,10,18,5]a = [10, 10, 18, 5] .
  • For the fourth query we can choose i=2i = 2 . So the value is lcm(10,12)gcd(10,12)=602=30\frac{\operatorname{lcm}(10, 12)}{\gcd(10, 12)} = \frac{60}{2} = 30 .
首页