Solve SRM 154DIV1 350 points