An explorer finds the door of an underground treasure house in desert ruins. Two positive integers a and b are carved on the door, and the lock opens only after the problem posed by those two numbers is solved.
Choose positive integers a1,a2,b1,b2 with a=a1×a2 and b=b1×b2. The four numbers may be equal to each other. Sort the four numbers in non-decreasing order as x1≤x2≤x3≤x4 and compute (x2−x1)2+(x3−x2)2+(x4−x3)2. Find the smallest value this expression takes over all choices.
For example, with a=33 and b=40, the factorizations 33=3×11 and 40=5×8 give the sequence 3,5,8,11. Its value is (5−3)2+(8−5)2+(11−8)2=22, and no choice gives a smaller value.