\(\text{Code}\)
for(int S = 0; S < (1 << n); S++)
for(int T = S; T; T = (T - 1) & S)
//do something
\(\text{Explanation}\)
\(T\) 为 \(S\) 的子集,且枚举子集的复杂度是 \(O(3^n)\)
2024-04-02 10:13:34
for(int S = 0; S < (1 << n); S++)
for(int T = S; T; T = (T - 1) & S)
//do something
\(T\) 为 \(S\) 的子集,且枚举子集的复杂度是 \(O(3^n)\)
下一篇:OCJP 考试题之九