Problems > The Two Missing Numbers > Editorial

The Two Missing Numbers — Solution & Editorial

Back to the Problem

Compare the expected sum and sum-of-squares with the actual ones: a+b and a²+b² determine a and b via the quadratic (integer square root of the discriminant).

Complexity: O(N)

Watch out: The sum of squares reaches ~1013·N — Python is safe; C++ needs unsigned 64/128 care.