Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define MAXBITS 32
- int main()
- {
- int n, k;
- cin >> n >> k;
- assert(n >= k && n <= 10);
- int b = 1 << n;
- for (int a = 0; a < b; a++)
- {
- cerr << "nr: " << a << ' ';
- cerr << "bits(rev): ";
- for (int i = 0; i < MAXBITS; i++)
- cerr << bool(a & (1 << i));//repr e inversa
- cerr << "poz: ";
- for (int i = 0; i < MAXBITS; i++)
- if (a & (1 << i))
- cerr << i << ' ';
- //comb
- cerr << "comb: ";
- int cnt = 0;
- for (int i = 0; i < MAXBITS; i++)
- if (a & (1 << i))
- cnt++;
- if (cnt == k)
- for (int i = 0; i < MAXBITS; i++)
- if (a & (1 << i))
- cerr << i << ' ';
- cerr << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement