Let’s first work out the ordinary DP equation for this problem. Obviously, after maintaining prefix sums, at \(f[i]\) we just enumerate a point \(j\) to split at:
Continue reading →Chinese original · English translation by Claude Opus 5.5
This problem is pretty interesting; at the end of the day it all comes down to bitwise operations. First, a sufficient conclusion is that the probability of picking an interval of length \(1\) is \(\frac{1}{N^2}\), while for length greater than 1 it is \(\frac{2}{N^2}\). Then, enumerate over the length of an \(int\), \(i \in [0,30]\), put the \(i\)-th bit of every number into a sequence and scan it, and when the scan reaches the \(j\)-th number, do case analysis.
Continue reading →Chinese original · English translation by Claude Opus 5.5