发现B题一个很精致的写法

#include<bits/stdc++.h>
using namespace std;
const int N=50;
int n,k,res=0;
int a[N];
void dfs(int x,int lenx){
    int t=0,y=x;
    while(x){
        if(x&1) t++;
        x=x>>1;
    }
    if(t==k) res++;
    for(int len=lenx+1;len<=n;len++){
        dfs(y&a[len],len);
    }
    return;
}
int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int len=1;len<=n;len++){
        dfs(a[len],len);
    }
    cout<<res;
    return 0;
}