This problem is used in private contest:814
条件控制