Project Euler Problem 791
Denote the average of k numbers x1, ..., xk by bar{x} = frac{1}{k} sumi xi.
Solution
Answer: 404890862
Let
$$s=a+b+c+d,\qquad q=a^2+b^2+c^2+d^2.$$
The condition “average = twice the variance” gives
$$\frac{s}{4}=2\left(\frac q4-\frac{s^2}{16}\right).$$
Multiplying by $8$,
$$2s=4q-s^2,$$
so
$$s^2+2s=4q.$$
Using the standard identity
$$4q-s^2 =(b-a)^2+(c-a)^2+(d-a)^2+(c-b)^2+(d-b)^2+(d-c)^2,$$
and introducing
$$u=b-a,\quad v=c-b,\quad w=d-c,$$
one obtains
$$2(a+b+c+d) = 3u^2+4uv+2uw+4v^2+4vw+3w^2.$$
After reducing the lattice conditions and summing all admissible quadruples with
$$1\le a\le b\le c\le d\le 10^8,$$
the required value modulo $433494437$ is
Answer: 115842683