| # | User | Rating |
|---|---|---|
| 1 | Benq | 3857 |
| 2 | jiangly | 3810 |
| 3 | maroonrk | 3534 |
| 4 | tourist | 3528 |
| 5 | Kevin114514 | 3510 |
| 6 | turmax | 3411 |
| 7 | Um_nik | 3387 |
| 8 | Radewoosh | 3367 |
| 9 | heuristica | 3322 |
| 10 | strapple | 3317 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 158 |
| 2 | maspy | 150 |
| 3 | Um_nik | 146 |
| 4 | Errichto | 139 |
| 5 | adamant | 136 |
| 6 | maroonrk | 134 |
| 7 | DNR | 133 |
| 8 | Dominater069 | 131 |
| 9 | Proof_by_QED | 130 |
| 9 | AmShZ | 130 |
Insomnia'26 Editorial
Problem C : Crushing the Array
Problem D : Disastrous Mex Problem for Saiki K
Problem H : Hiding from the Downpour
Problem J : Jaded Jeweler's Journey
Problem K : Kaguya's Mood Swings
Problem L : Leylines of Lumina
How many times can the prefix $$$\gcd$$$ sequence $$$x_i = \gcd(a_1,\dots,a_i)$$$ change?
It changes at most $$$O(\log A)$$$ times since each change makes it at least half.
After removing one element from a segment, what condition must the remaining $$$\gcd$$$ satisfy to become a target value after one modification?
You need:
where $$$g$$$ is the $$$\gcd$$$ after removal and $$$t$$$ is the target.
Define a function
For each index $$$i$$$, let
and define
We need to count all $$$i$$$ such that $$$f(P_i, S_i) = 1$$$.
A modification consists of changing at most one element in $$$P_i \cup S_i$$$. Observe that changing an element is equivalent to removing it and replacing it with a suitable value, hence it suffices to consider removal.
Thus, for a fixed $$$i$$$, the following cases arise:
(1) No modification:
(2) One removal in prefix: There exists $$$j \le i$$$ such that
(3) One removal in suffix: There exists $$$k \gt i$$$ such that
Hence,
Using the property that gcd values over prefixes and suffixes form at most $$$O(\log A)$$$ distinct values, we can efficiently maintain all possible gcds obtained by removing one element. Precomputing $$$x_i$$$ and $$$y_i$$$, and iterating over $$$i$$$, we check the above conditions in total $$$O(n \log A)$$$ time.
Lemma 1. (Prefix $$$\gcd$$$ changes $$$O(\log A)$$$ times)
Let $$$x_i = \gcd(a_1,\dots,a_i)$$$. Then $$$x_i$$$ takes $$$O(\log A)$$$ distinct values.
Proof.
If $$$x_{i+1} \ne x_i$$$, then $$$x_{i+1}$$$ is a proper divisor, so:
Thus after $$$k$$$ changes: $$$x_i \le A/2^k \ge 1 \Rightarrow k \le \log_2 A$$$.
Lemma 2. (Divisibility condition is sufficient and necessary)
Let $$$g = \gcd(P_i \setminus {a_j})$$$. Then one modification makes $$$\gcd(P_i)=y_i$$$ iff:
Proof.
If $$$y_i \mid g$$$, replace $$$a_j$$$ with $$$y_i$$$: $$$\gcd(g, y_i) = y_i$$$
| Rev. | Lang. | By | When | Δ | Comment | |
|---|---|---|---|---|---|---|
| en32 |
|
tridipta2806 | 2026-03-23 21:32:13 | 37 | ||
| en31 |
|
tridipta2806 | 2026-03-23 21:20:44 | 3 | (published) | |
| en30 |
|
tridipta2806 | 2026-03-23 21:20:29 | 2144 | ||
| en29 |
|
tridipta2806 | 2026-03-23 21:18:05 | 725 | ||
| en28 |
|
aastik231205 | 2026-03-23 20:52:07 | 13984 | ||
| en27 |
|
Forge | 2026-03-23 20:39:21 | 55 | ||
| en26 |
|
Forge | 2026-03-23 20:37:15 | 1 | ||
| en25 |
|
Forge | 2026-03-23 20:36:35 | 19 | ||
| en24 |
|
Forge | 2026-03-23 20:35:45 | 136 | ||
| en23 |
|
Forge | 2026-03-23 20:29:59 | 312 | ||
| en22 |
|
Forge | 2026-03-23 20:22:54 | 288 | ||
| en21 |
|
Forge | 2026-03-23 20:20:06 | 491 | ||
| en20 |
|
Forge | 2026-03-23 19:59:49 | 292 | ||
| en19 |
|
Forge | 2026-03-23 19:39:02 | 36 | ||
| en18 |
|
Forge | 2026-03-23 19:37:11 | 20 | ||
| en17 |
|
tridipta2806 | 2026-03-23 19:32:10 | 498 | ||
| en16 |
|
tridipta2806 | 2026-03-23 19:27:27 | 68 | ||
| en15 |
|
tridipta2806 | 2026-03-23 19:22:19 | 13201 | ||
| en14 |
|
tridipta2806 | 2026-03-23 19:14:09 | 17 | ||
| en13 |
|
tridipta2806 | 2026-03-23 19:11:05 | 19886 | ||
| en12 |
|
tridipta2806 | 2026-03-23 17:38:28 | 1822 | ||
| en11 |
|
shorya1835 | 2026-03-23 17:21:23 | 45 | ||
| en10 |
|
tridipta2806 | 2026-03-23 16:59:13 | 2 | ||
| en9 |
|
tridipta2806 | 2026-03-23 16:56:56 | 3117 | ||
| en8 |
|
tridipta2806 | 2026-03-23 16:51:10 | 28 | ||
| en7 |
|
tridipta2806 | 2026-03-23 16:49:28 | 4895 | ||
| en6 |
|
tridipta2806 | 2026-03-23 13:56:04 | 4764 | ||
| en5 |
|
tridipta2806 | 2026-03-23 13:25:23 | 1197 | ||
| en4 |
|
tridipta2806 | 2026-03-23 13:24:38 | 1142 | ||
| en3 |
|
tridipta2806 | 2026-03-23 10:35:10 | 11 | ||
| en2 |
|
tridipta2806 | 2026-03-23 10:34:34 | 4850 | ||
| en1 |
|
tridipta2806 | 2026-03-22 21:42:58 | 3996 | Initial revision (saved to drafts) |
| Name |
|---|


