This problem is in Contest(s) below:
Contest 1987:算法基础班结业测试
Contest 1179:test-task
Contest 1920:七、八年级基础算法复习题目