1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull;
ll checknum[100], n, m;
#define rep(i, a, n) for (ll i = a; i < n; ++i) #define per(i, a, n) for (ll i = n - 1; i >= a; --i)
void print_subset(ll n, ll m) { ll ans = 0; rep(i, 0, (1 << n)) { ans++; int flag = 1; rep(j, 0, m) { if (((1 << checknum[j]) & i) == 0) { flag = 0; break; } } if (!flag) continue; cout << ans - 1 << ":"; rep(j, 0, n) { if ((1 << j) & i) cout << " " << j; } cout << endl; } }
int main() { ios::sync_with_stdio(false); while (cin >> n) { memset(checknum, 0, sizeof(checknum)); cin >> m; rep(i, 0, m) cin >> checknum[i]; print_subset(n, m); } }
|