File tree 1 file changed +3
-3
lines changed
1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -7,13 +7,13 @@ author: Ryan Chou
7
7
8
8
<Spoiler title = " Hint 1" >
9
9
10
- Can we upper bound the number of times the GCD changes?
10
+ Can we upper bound the number of times the GCD changes when extending a singular subarray ?
11
11
12
12
</Spoiler >
13
13
14
14
<Spoiler title = " Answer to Hint 1" >
15
15
16
- Note that the GCD can only decrease, and it will always remove some factor from the current GCD.
16
+ Note that the GCD can only decrease as we add more elements , and it will always remove some factor from the current GCD.
17
17
The smallest factor we can remove is $2$, and $a_i \leq 10^9$, so the GCD can only change at most
18
18
$log_2(10^9) \approx 30$ times.
19
19
@@ -26,7 +26,7 @@ $log_2(10^9) \approx 30$ times.
26
26
Since we know that the larger the subarray is, the GCD will never increase, we can create a list of hashmaps where
27
27
$\texttt{ max \_size } _ { i , \text {gcd }} =$ the maximum size of the subarray ending at $i$ with a GCD of $\text{ gcd } $.
28
28
29
- Then, we can perform updates in $\mathcal{ O } (\log N)$ by extending subarrays that ended at index $i - 1$ to index $i$.
29
+ Then, we can perform updates in $\mathcal{ O } (\log N)$ time by extending subarrays that ended at index $i - 1$ to index $i$.
30
30
31
31
The answer for length $\texttt{ len } $ will be the maximum $\text{ gcd } $ for which $\texttt{ max \_size } _ { i , \text {gcd }} = \texttt{ len } $
32
32
You can’t perform that action at this time.
0 commit comments