This problem is in Contest(s) below:
Contest 1143:基础班-模拟
Contest 1157:统计与计数