CF1732E.Location
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given two arrays of integers a1,a2,…,an and b1,b2,…,bn . You need to handle q queries of the following two types:
- 1 l r x : assign ai:=x for all l≤i≤r ;
- 2 l r : find the minimum value of the following expression among all l≤i≤r : $$$$\frac{\operatorname{lcm}(a_i, b_i)}{\gcd(a_i, b_i)}. $$
In this problem gcd(x,y) denotes the greatest common divisor of x and y , and operatornamelcm(x,y) denotes the least common multiple of x and y$$.
输入格式
The first line contains two integers n and q ( 1≤n,q≤5⋅104 ) — the number of numbers in the arrays a and b and the number of queries.
The second line contains n integers a1,a2,…,an ( 1≤ai≤5⋅104 ) — the elements of the array a .
The third line contains n integers b1,b2,…,bn ( 1≤bi≤5⋅104 ) — the elements of the array b .
Then q lines follow, j -th of which starts with an integer tj ( 1≤tj≤2 ) and means that the j -th query has type tj .
If tj=1 , it is followed by three integers lj , rj , and xj ( 1≤lj≤rj≤n , 1≤xj≤5⋅104 ).
If tj=2 , it is followed by two integers lj and rj ( 1≤lj≤rj≤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.
输入输出样例
输入#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=4 . So the value is gcd(4,4)lcm(4,4)=44=1 .
- After the second query the array a=[6,10,15,4,9,25,9,9,9,9] .
- For the third query we can choose i=9 . So the value is gcd(9,18)lcm(9,18)=918=2 .
In the second:
- For the first query we can choose i=4 . So the value is gcd(1,5)lcm(1,5)=15=5 .
- After the second query the array a=[10,18,18,5] .
- After the third query the array a=[10,10,18,5] .
- For the fourth query we can choose i=2 . So the value is gcd(10,12)lcm(10,12)=260=30 .