C - Minimize Abs 2 Editorial by evima

Illustration by Proposer

There is nothing to add to the official explanation regarding the solution, but I will roughly illustrate what is being calculated.

(\(x^2 + y^2\) can be understood as the square of the Euclidean distance from the origin \((0,0)\) to \((x,y)\) on the \(xy\) plane, and the set of points that satisfy \(x^2 + y^2 = D\) forms a circle with radius \(\sqrt D\) centered at the origin. The problem, roughly speaking, is to find the lattice point that is “closest” to this circumference.)

posted:
last update: