This repository was archived by the owner on Mar 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatement_md.txt
58 lines (46 loc) · 1.63 KB
/
statement_md.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Mirzapur Election
Jas and Ashish are the President and Vice-president of CSIT Party and are working hard to win the elections of Mirzapur.
There are **N** states in Mirzapur, whose vote counts on Day 0 are given. (*count[0,....,n-1]*) .
Next **D** days, either the vote count of a state gets updated, or the election commission wants Jas and Ashish to submit their Max-Potential Value.
**Max-Potential** = maximum of gcd(count[i],count[j]), for all i, j. ($ 0 \leq i, j \leq n-1, i \neq j $).
Mathematically, the two operations can be defined as:
* **[1 i x]**: Update voteCount of state i to x. (*count[i] = x*).
* **[2]**: Output Max-Potential.
See the explanation of sample test cases, for more clarity.
Warning: **Use Fast IO**
###Input
* The first line contains space-separated integers **N, D**.
* The second line contains N space-separated integers **count[0],count[1] ...count[n-1]**.
* Next **D** line contains input corresponding to one of the operations mentioned below.
* Operation 1: **1 i x** (3 space-separarted integer)
* Operation 2: **2**
###Output
For every Operation 2, output the Max-Potential on a new line.
###Constraints
* $2 \leq N \leq 100000$
* $1 \leq D, x \leq 100000$
* $0 \leq i \leq n-1$
* $1 \leq count[i] \leq 100000$
###Example Input
```
5 5
1 1 3 4 5
2
1 1 2
2
1 4 3
2
```
###Example Output
```
1
2
3
```
###EXPLANATION:
* On Day 0, count = [1,1,3,4,5]
* On Day 1, Max-Potential = 1, gcd of all pairs of states is 1.
* On Day 2, count = [1,2,3,4,5]
* On Day 3, Max-Potential = 2, gcd of states 1,3 is gcd(2,4) = 2.
* On Day 4, count = [1,2,3,4,3]
* On Day 5, Max-Potential = 3, gcd of states 2,4 is gcd(3,3) = 3.