The Matchstick Experiment
The answer can be decomposed into a sum of multiple random variables, each of which is represented as the probability that a specific shape appears in some position. Then apply linearity of expectation to get the answer.
Number of M-Coprime Arrays
Factorizing
The Axis of Awesome
Consider some axis given by its direction vector
Note,
The real symmetric matrix
Given an axis
Without loss of generality, assume
. Add a . So the answer is 1. . It is impossible to raise both and with one point because will be positive, thus will not be diagonal. Add a to convert to the case, then add another. So the answer is 2.
The answer is
iff has a double root, that is, its discriminant equals to 0. iff and . . is also the smaller root of . The converse also holds. So we can take the smaller root of and see if it is also the root of . If it is, must have a multiplicity of at least 2 at the smaller root. Because we know , it must be 2. iff and .
Painting Figures
Calculate the area of the union of some rectangles and circles.
Sweep line algorithm
Green's theorem
By Green's theorem, the area of a region enclosed by a smooth and closed curve can be calculated by a line integral. To use Green's theorem, we need to find the boundary of the region, which is a set of arcs (circles splitted by circles or rectangles) and segments (rectangles splitted by circles or rectangles).
Keep an eye on which lines to calculate because line integrals are very sensitive to degeneracies. I make numerical perturbation to the position of points which allows me to ignore special cases.