| # | User | Rating |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3611 |
| 4 | jiangly | 3583 |
| 5 | strapple | 3515 |
| 6 | tourist | 3470 |
| 7 | dXqwq | 3436 |
| 8 | Radewoosh | 3415 |
| 9 | Otomachi_Una | 3413 |
| 10 | Um_nik | 3376 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 164 |
| 2 | adamant | 150 |
| 3 | Um_nik | 146 |
| 4 | Dominater069 | 144 |
| 5 | errorgorn | 141 |
| 6 | cry | 139 |
| 7 | Proof_by_QED | 136 |
| 8 | YuukiS | 135 |
| 9 | chromate00 | 134 |
| 9 | TheScrasse | 134 |
|
On
commandox →
[2026 in progress] [v1.0.1] OI-TED-ARCHIVE — Preserve OI resources before they disappear, 3 months ago
0
Great Effort. :) |
|
0
Glad you liked it. Updated the wording in P2. |
|
0
Auto comment: topic has been updated by dominique38 (previous revision, new revision, compare). |
|
0
Glad you liked it |
|
+13
I nominate this |
|
0
Auto comment: topic has been updated by dominique38 (previous revision, new revision, compare). |
|
+7
It's a good solution indeed. Hopefully not just for myself, the crucial part feels a little vague.
My attempt to explain it more elaborately.
Proof $$$S = 2 + 3 + 4 + \cdots + n = \frac{n(n+1)}{2} - 1$$$ . The first inequality $$$n \gt x $$$ can be proven via proof by contradiction and, showing it's only possible for $$$n \lt 4$$$. Lets say $$$x=n$$$, which means $$$x^2 \geq S $$$ and $$$(x-1)^2 \lt S$$$. I can break $$$n (n-1)$$$ into parts since it's an even integer; I need to be careful when dealing with integers. Since $$$n \gt 1$$$, we can cancel on both sides, which yields the result that $$$n$$$ must be less than $$$4$$$ and leads to a contradiction. The upper bound is quite loose. For the trivial case where $$$x^2=S$$$ (as with $$$n=4$$$), we've already found our answer. The only case remaining is $$$n \geq 5$$$, and we now just need to prove that $$$x^2 - S \gt 0$$$. We will use two properties of the ceiling function: Using the first ceiling property, we can say that the first ceiling term is at least as big as the second term. Therefore, we can see that the LHS is at least $$$1$$$ integer larger. It feels like I have overcomplicated things very much. Sorry. Corollary: Taking $$$d = x^2 - S$$$, then $$$2 \sqrt S \gt d$$$ must be true. Proof If $$$x^2 \geq S$$$, then $$$(x-1)^2 \lt S$$$. This implies that $$$x \leq \lceil \sqrt S \rceil + 1$$$. From the Ceiling property, we can say the remaining terms are greater than 0. Therefore, $$$d \lt 2 \lceil \sqrt S \rceil$$$. This is approximately $$$d \approx \sqrt 2 n$$$. In practice, its $$$d/n$$$ ratio is $$$\approx 1.45455$$$. Now, our initial tree is rooted at $$$1$$$, and all other nodes are directly connected to $$$1$$$ as leaves. Now I want to rearrange the leaves such that my sum is increased by $$$d(=x^2-S)$$$. Let's say we pluck the leaf $$$v$$$ and attach it to $$$u$$$. Then our new sum, $$$S_{\text{new}}$$$, is calculated as: If the required increment satisfies $d \leq n$, we can choose the parent $$$u=2$$$ and the leaf $$$v=d$$$. Our job will be done in a single step. If $$$d \gt n$$$, we need a multi-step approach. We claim that we can always find $$$v_1$$$ and $$$v_2$$$ such that $$$n \geq v_1, v_2 \gt 2$$$ and their sum is $$$d$$$. One possible method for partitioning $$$d$$$ into two parts (given $$$d \gt n$$$):
For $$$n \geq 5$$$, these vertices $$$v_1$$$ and $$$v_2$$$ will be $$$\geq 3$$$ in both cases. But if $$$d=1$$$ or $$$d=2$$$, we need to be a little careful. Submission link 344535551 Edit1: Mistake: In calculating $$$x^2$$$ and in using the Ceiling property $$$\lceil x_1 \cdot x_2 \rceil \leq \lceil x_1 \rceil \cdot \lceil x_2 \rceil $$$, I mistakenly took the lower bound of this product when determining the upper bound. That was a stupid mistake. The following edits are made:
|
|
0
In the forum we are given a prime $$$MOD (= 998244353)$$$ and the solution in the forum is using that fact too, but how do we find summation for arbitrary $$$MOD$$$ in subquadratic time, where we are not guaranteed modulo inverse exists? |
|
On
Ripatti →
A little bit of classics: dynamic programming over subsets and paths in graphs, 3 years ago
0
I noticed a minor issue(maybe typo) in the transition of the DP state in P4 : Checking the existence of the Hamiltonian walk in $$$O(2^{n} \cdot n)$$$, since I'm writing a comment anyway let me explain with a little more detail which smol idea help us optimize it from $$$O(2^{n} \cdot n^2)$$$ to $$$O(2^{n} \cdot n)$$$ . Idea — Since we only need a binary (yes/no) answer for each vertex $$$j$$$ in $$$mask$$$ to see whether it can reach $$$i$$$, we can use mask $$$X$$$ to store all that information instead of using $$$j$$$ (which is iterating over all $$$n$$$), this saves us extra $$$O(n)$$$. Def. — $$$dp'[mask]~=~X$$$, $$$X$$$ is a subset of the $$$mask$$$, where the set-bits in $$$X$$$ indicate the vertices that allow for a successful Hamiltonian Walk across $$$mask$$$ which ends at the set-bit vertex. Transition — For $$$i$$$-th bit that is set in $$$mask$$$ , we need to know whether $$$dp'[mask \oplus 2^{i}]$$$'s successful Walks can reach $$$i$$$-th vertex, for that we need to precalculate $$$M_{i}$$$, $$$M_{i} = $$$ mask made of vertices that are incident to $$$i$$$. If $$$M_{i}$$$ and $$$dp[mask \oplus i]$$$ share vertices we can extend our successful Walk towards $$$i$$$ and set $$$dp'[mask]$$$'s $$$i$$$-th bit as $$$1$$$. Base — $$$dp'[2^{i}] = 2^{i}$$$ for every $$$i \le n$$$. |
|
+7
This relation is pretty interesting :) Important GCD properties we will use are
Let assume $$$a \gt b$$$, the base cases are $$$F_{0}=0$$$, $$$F_{1}=1$$$ and $$$F_{2}=1$$$ . Claim $$$I$$$ : Every 2 consecutive Fibonacci numbers will always be co-prime $$$gcd(F_{a+1},F_{a})=1$$$. Proof I Proof $$$I$$$ : Using $$$1$$$-st GCD property we can say, we back to $$$gcd(F_{a},F_{a-1})$$$ same relation just 1 step down and by induction we can bring it finally down to $$$gcd(F_{2},F_{1}) = 1$$$, which proves our claim. Claim $$$II$$$ : $$$gcd(F_{a},F_{b}) = gcd(F_{a-b},F_{b})$$$ Proof II We know $$$F_{a+1}$$$ and $$$F_{a}$$$ are co-prime, lets start by counting $$$F_{a+1}$$$ after decaying of $$$F_{a+ \Delta}$$$ and use $$$3$$$-rd GCD property to comment on $$$\Delta$$$ which diretly relates to $$$a-b$$$ in our claim. We are ignoring count of $$$F_{a}$$$ after decaying of $$$F_{a+ \Delta}$$$ because we can always erase its presense using $$$1$$$-st GCD property. Lets start counting simple, Counting slowly to see pattern . . . Case $$$1$$$ : $$$gcd(F_{a+2},F_{a})$$$ , lets count how much which gives us $$$1$$$, Case $$$2$$$ : $$$gcd(F_{a+3},F_{a})$$$ , lets count how much which gives us $$$2$$$, Case $$$3$$$ : $$$gcd(F_{a+4},F_{a})$$$ , lets count how much which gives us $$$3$$$, For case $$$4$$$ you will get count = $$$5$$$, If we see cleverly $$$Cnt_{x} = Cnt_{x-1} + Cnt_{x-2}$$$, count given by 2 decays which is also Fibonacci number, which gives us $$$Cnt_{\Delta} = F_{\Delta}$$$. Now lets bring $$$b$$$ and $$$a$$$ into picture like we used in our Claim $$$II$$$, where $$$a = b + \Delta$$$. which proves our claim. Corollary from Claim $$$II$$$ : $$$gcd(F_{a},F_{b}) = gcd(F_{b},F_{a \% b})$$$ , from GCD property $$$1$$$ we can keep on subtracting $$$b$$$ till $$$a-kb \geq 0$$$ which gives us $$$a \% b$$$ at the end. Final Steps :
which proves the interesting relation between $$$gcd$$$ and Fibonacci. |
|
On
kazamasmile →
Made a 3blue1brown-style animation exploring the solution to one of my favorite problems!, 4 years ago
+7
very well explained and pretty well animated! Thats a very good start! :) |
| Name |
|---|


