This problem is in Contest(s) below:
Contest 1677:ACM可好玩了(2)
Contest 1632:JAVA组测试