This documentation is automatically generated by online-judge-tools/verification-helper
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/lesson/8/ITP2/all/ITP2_11_D"
#include "./../Utility/BitRangeBasedFor.cpp"
#include <iostream>
using namespace std;
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int n, k;
cin >> n >> k;
for (long long bit : bit_comb(k, n)) {
cout << bit << ':';
for (int i = 0; i < n; ++i) {
if (bit & (1 << i)) cout << ' ' << i;
}
cout << '\n';
}
}
#line 1 "test/BitRangeBasedFor.test.cpp"
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/lesson/8/ITP2/all/ITP2_11_D"
#line 2 "Utility/BitRangeBasedFor.cpp"
class bit_subset {
struct it {
long long sub, s;
bool f = false;
it(long long x) : sub(x), s(x) {}
long long operator*() const {
return sub;
}
void operator++() {
sub = (sub - 1) & s;
f |= sub == s;
}
bool operator!=([[maybe_unused]] const it& i) const {
return !f;
}
} b, e;
public:
bit_subset(long long s) : b(s), e(s) {}
it begin() const {
return b;
}
it end() const {
return e;
}
};
class bit_comb {
struct it {
long long s;
it(long long x) : s(x) {}
long long operator*() const {
return s;
}
void operator++() {
long long x = s & -s, y = s + x;
s = ((s & ~y) / x >> 1) | y;
}
bool operator!=(const it& i) const {
return s < i.s;
}
} b, e;
public:
bit_comb(int k, int n) : b((1LL << k) - 1), e(1LL << n) {}
it begin() const {
return b;
}
it end() const {
return e;
}
};
#line 3 "test/BitRangeBasedFor.test.cpp"
#include <iostream>
using namespace std;
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int n, k;
cin >> n >> k;
for (long long bit : bit_comb(k, n)) {
cout << bit << ':';
for (int i = 0; i < n; ++i) {
if (bit & (1 << i)) cout << ' ' << i;
}
cout << '\n';
}
}