TopCoder SRM345d2 – 250 :: C++