TopCoder SRM617: correct div2_3.cpp