This problem is in Contest(s) below:
Contest 1166:枚举算法入门
Contest 1197:2026春季入门班练习