Topcoder: SRM594_div2