First, within the residue system of \(Q\) we enumerate numbers \(x_0\), and write each of them as \(x = (x_0 + k * P) \mod Q\). Thinking about it a bit, we find that these numbers change with \(k\), and they show a periodic pattern: that is, these numbers lie on a cycle. We can consider recording, for every number in the residue system of \(Q\), its contribution in \(P\), recording it as prefix sums, and when computing the answer, compare ranks to determine the direction around the cycle (the long arc or the short arc).
Continue reading →Chinese original · English translation by Claude Opus 5.5
This is a textbook problem that tests knowledge of Möbius inversion and Dirichlet convolution.
Here we stipulate \(n<m\); swapping the two does not affect the answer. Then let's observe the counting pattern: we find that each point contributes at least \(1\) to the answer, and the extra contribution is actually twice the number of lattice points (points with integer coordinates) on the current segment other than the point itself. In other words:
Continue reading →Chinese original · English translation by Claude Opus 5.5
At first I had no clue at all; after reading the solution it all suddenly clicked (duh, doesn't everything click once you've read the solution?). The problem asks us to compute:
The concise statement is very pleasant. With \(gcd\) showing up, we can think in the direction of inversion. First, the usual standard trick: enumerate the \(gcd\). For convenience of writing, I'll drop the modulo here.
Continue reading →Chinese original · English translation by Claude Opus 5.5
Math problems in OI contests at the provincial team selection level and above are much harder than NOIp math problems. In this post I'll record some of what I took away from learning Möbius inversion and Du's sieve. Here is the outline of this post:
The first question is fairly easy. Let the state \(f[i]\) be the expected depth when there are \(i\) leaf nodes. Considering that a split from the previous state contributes an extra \(f[i-1]+2\) to the total depth, we know:
Our state won't take the current round into account: that would be too hard to design, and I'm too weak to manage it. Let's design a global state: \(f[i][j]\) is the probability that, considering the first \(i\) cards, only \(j\) cards have been activated by the time the game ends. Then the answer is:
Continue reading →Chinese original · English translation by Claude Opus 5.5
This problem is still pretty godlike: the formula is fairly easy to derive, but the Gaussian elimination part is a bit of a pain.
First we enumerate the destination \(t\), and let the state \(f[i][j]\) be the probability that the people at \(i,j\) transition to \(t\). Consider the following formula:
Continue reading →Chinese original · English translation by Claude Opus 5.5
This DP problem is very well set: it tests a contestant's ability to transform the model.
Person \(i\) says: “There are \(ai\) people who scored higher than me, and \(bi\) people who scored lower than me.”
Each statement can be seen as a segment \([a_i+1,n-b_i]\) on a one-dimensional coordinate line, meaning the people on this segment have equal scores. Clearly, in every valid case these segments do not intersect (complete overlap is allowed). So sort the segments by left endpoint, and this \(dp\) equation, keyed by coordinate, should be written as:
Continue reading →Chinese original · English translation by Claude Opus 5.5