#P6299. Minimum Nonzero Difference Degree
Minimum Nonzero Difference Degree
Minimum Nonzero Difference Degree
Given four integers \(a, b, c, d\), define the difference degree \(M\) for integers \(p, q, r, s\) by
\[ M = \Big| (a^2+b^2)(p^2+q^2) + (c^2+d^2)(r^2+s^2) + 2\,(ac+bd)\,(pr-qs) + 2\,(bc-ad)\,(ps+qr) \Big|. \]
Your task is to find the minimum nonzero value of \(M\) and one corresponding quadruple \((p, q, r, s)\) for which \(M\) attains that value. It is guaranteed that the minimum nonzero \(M\) exists, is less than \(2^{63}\), and that there exists a solution with \(|p|, |q|, |r|, |s| .
inputFormat
Four space‐separated integers: a, b, c, d.
outputFormat
Output five space‐separated integers: the minimum nonzero value of (M), followed by a corresponding quadruple (p, q, r, s).
sample
1 0 0 1
1 0 0 1 0
</p>