Skip to content

Commit 1c6415b

Browse files
authored
Merge pull request #4386 from cpinitiative/ksizegcd_quickfix
looks good to me
2 parents 67a025b + fa92193 commit 1c6415b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

solutions/gold/cc-KSIZEGCD.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ author: Ryan Chou
77

88
<Spoiler title="Hint 1">
99

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?
1111

1212
</Spoiler>
1313

1414
<Spoiler title="Answer to Hint 1">
1515

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.
1717
The smallest factor we can remove is $2$, and $a_i \leq 10^9$, so the GCD can only change at most
1818
$log_2(10^9) \approx 30$ times.
1919

@@ -26,7 +26,7 @@ $log_2(10^9) \approx 30$ times.
2626
Since we know that the larger the subarray is, the GCD will never increase, we can create a list of hashmaps where
2727
$\texttt{max\_size}_{i, \text{gcd}} =$ the maximum size of the subarray ending at $i$ with a GCD of $\text{gcd}$.
2828

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$.
3030

3131
The answer for length $\texttt{len}$ will be the maximum $\text{gcd}$ for which $\texttt{max\_size}_{i, \text{gcd}} = \texttt{len}$
3232

0 commit comments

Comments
 (0)