C++ Solution for Mathema - "Ghosh, Arun" (New Delhi, 2005)