UVa 543 - Goldbach's Conjecture

543 - Goldbach's Conjecture

 * http://acm.uva.es/p/v5/543.html

Summary
Goldbach's Conjecture is unproven, but is true for the input. (You will not have to print "Goldbach's conjecture is wrong.") Simply use the sieve, and use a naive algorithm, starting from $$\frac{n}{2}$$ going outwards, minimizing the distance between the two numbers.

Explanation
Goldbach's Conjecture have been confirmed up to very large numbers, and this is a trivial problem, given that you know how to implement the Prime Sieve of Eratosthenes.

A C++ solution from an unknown user with IP 89.108.249.161:

Input
8 20 42 0

Output
8 = 3 + 5 20 = 3 + 17 42 = 5 + 37