#GL0000389. Vị trí tối ưu (Location)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Vị trí tối ưu (Location)
Location
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You are given two arrays and of positive integers. Array is fixed, while array can be modified.
Process operations in order:
1 l r x: assign for every .2 l r: output the minimum over of
Both GCD and LCM are taken on positive integers, so the expression is a positive integer.
Input
- First line: .
- Second line: integers .
- Third line: integers .
- Next lines: operations of type
1 l r xor2 l r.
At least one type-2 query is guaranteed.
Output
For every type-2 query print the required minimum on its own line.
Subtasks
-
Subtask 1 (20 points): ; ; .
-
Subtask 2 (30 points): ; ; .
-
Subtask 3 (50 points): ; ; .
Examples
Example 1
Input
4 4
10 2 12 5
1 12 16 1
2 2 4
1 2 3 18
1 2 2 10
2 2 3
Output
5
30
Explanation
Initially positions have ratios ; the minimum is . After both assignments, position has ratio while position has ratio , so the second answer is .
Example 2
Input
3 4
4 6 9
6 6 3
2 1 3
1 1 3 6
2 1 3
2 3 3
Output
1
1
2
Explanation
The first range contains two equal values at position , so its minimum is . Assigning for all positions makes the second minimum . Finally, the ratio at position is .