Solve SRM 152DIV1 250points