This problem is in Contest(s) below:
Contest 1311:ACM训练题三(大二)