dgoon solved 2010/A[12] (http://ipsc.ksp.sk/2010/real/problems/a.html)