Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- #define pb push_back
- using namespace std;
- int main() {
- int n, k;
- cin >> n >> k;
- int w[n];
- for (int i = 0; i < n; ++i) {
- cin >> w[i];
- }
- if (n > 20) {
- cout << "1";
- return 0;
- }
- int ans = 0;
- for (int mask = 0; mask < (1 << n); ++mask) {
- int cur = 0;
- set<int> b;
- for (int i = n - 1; i >= 0; --i) {
- if ((mask & (1 << i)) != 0) {
- cur++;
- b.insert(w[i]);
- }
- }
- if (cur == k && b.size() == k) {
- ans++;
- }
- }
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement