This problem is in Contest(s) below:
Contest 1282:计数问题
Contest 1470:组合数学进阶