一个神奇的算法,在题目中看到的,单独拿出来整理枚举一个集合S(用一个二进制表示)的所有子集S0:for(int S0 = S; S0; S0 = (S0-1)&S){}还有不包括S本身的:
for(int S0 = (S-1)&S; S0; S0 = (S0-1)&S){}