This problem is in Contest(s) below:
Contest 1016:NOIP枚举
Contest 1058:小学省赛集训枚举专题