This problem is in Contest(s) below:
Contest 5267:python-王-穷举法进阶练习