模拟 使用数字二进制表示子集 0:不选择, 1: 选择
static const auto is_sync_off = [](){ ios::sync_with_stdio(false); cin.tie(0); return nullptr; }(); class Solution { public: vector<vector<int> > subsets(vector<int> &S) { int slength = S.size(); int mask = (1 << slength) - 1; vector<vector<int>> res{}; res.push_back(vector<int>{}); for (int k = 1; k <= mask; k++) { vector<int> t{}; for (int j = 0; j <= 5; j++) { if(k & (1 << j)) { t.push_back(S[j]); } } res.push_back(t); } return res; } };