| 记录编号 | 
        487848 | 
        评测结果 | 
        AAAAAAAAAA | 
    
    
        | 题目名称 | 
        2902.博士的密码 | 
        最终得分 | 
        100 | 
            
    
    
        | 用户昵称 | 
         CSU_Turkey | 
        是否通过 | 
        通过 | 
    
    
        | 代码语言 | 
        C++ | 
        运行时间 | 
        0.366 s  | 
    
    
        | 提交时间 | 
        2018-02-12 16:59:41 | 
        内存使用 | 
        0.16 MiB  | 
        
    
    
    
    		显示代码纯文本
		
		#include<bits/stdc++.h>
#define LL long long
using namespace std;
int n,a[41];
LL ans,key;
bool b[41];
map<LL,int>S;
void dfs1(int x){
	if(x==n/2+1){
		LL tmp=0;
		for(int i=1;i<=n/2;i++)
			if(b[i])tmp+=a[i];
		if(!S.count(tmp))S.insert(make_pair(tmp,1));
		else S[tmp]++;
		return ;
	}
	b[x]=1;
	dfs1(x+1);
	b[x]=0;
	dfs1(x+1);
}
void dfs2(int x){
	if(x==n+1){
		LL tmp=0;
		for(int i=n/2+1;i<=n;i++)
			if(b[i])tmp+=a[i];
		if(S.count(key-tmp)){
			ans+=S[key-tmp];
		}
		return ;
	}
	b[x]=1;
	dfs2(x+1);
	b[x]=0;
	dfs2(x+1);
}
int main()
{
	freopen("password1.in","r",stdin);
	freopen("password1.out","w",stdout);
	scanf("%d%lld",&n,&key);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	dfs1(1);
	dfs2(n/2+1);
	printf("%lld\n",ans);
	return 0;
}