解题思路:由于n很小我们很容易就想到用二进制解决这个问题,那么就是将每个集合变成一个数,然后用&判断就行了
代码:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int mx = 2e2+10;
int n;
double a;
int cnt[mx];
int main(){
scanf("%d%lf",&n,&a);
int x,y = 0,top = 0;
while(~scanf("%d",&x)){
char c = getchar();
x--;
y += (1<<x);
while(c!='\n'){
scanf("%d",&x);
x--;
c = getchar();
y += (1<<x);
}
cnt[top++] = y;
y = 0;
}
int sum = (1<<n);
a = a*top;
int ans = 0;
for(int i=1;i<sum;i++){
int to = 0,po,size = 0;
for(int j=0;j<top;j++){
if((i&cnt[j])==i) size++;
}
if(size>=a) ans++;
}
printf("%d\n",ans);
return 0;
}