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