| 记录编号 | 
        584550 | 
        评测结果 | 
        AAAAAAAAAA | 
    
    
        | 题目名称 | 
        2902.博士的密码 | 
        最终得分 | 
        100 | 
            
    
    
        | 用户昵称 | 
         Murasame | 
        是否通过 | 
        通过 | 
    
    
        | 代码语言 | 
        C++ | 
        运行时间 | 
        0.071 s  | 
    
    
        | 提交时间 | 
        2023-11-13 16:20:17 | 
        内存使用 | 
        1.18 MiB  | 
        
    
    
    
    		显示代码纯文本
		
		#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,key1,ans=0;
ll a[45];
map<ll,int> mp;
void dfsfront(int x,ll w){
	if(x==n/2){
		mp[w]++;
		return;
	}
	dfsfront(x+1,w+a[x+1]);
	dfsfront(x+1,w);
}
void dfsback(int x,ll w){
	if(x==n){
		ans+=mp[key1-w];
		return;
	}
	dfsback(x+1,w+a[x+1]);
	dfsback(x+1,w);
}
int main(){
	freopen("password1.in","r",stdin);
	freopen("password1.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>key1;
	memset(a,0,sizeof(a));
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	dfsfront(0,0);
	dfsback(n/2,0);
	cout<<ans<<endl;
	return 0;
}