This problem is in Contest(s) below:
Contest 1451:训练六
Contest 1146:CSP培训班练习题(四)