| 记录编号 | 
        584540 | 
        评测结果 | 
        AAAAAAAAAA | 
    
    
        | 题目名称 | 
        2902.博士的密码 | 
        最终得分 | 
        100 | 
            
    
    
        | 用户昵称 | 
         元始天尊 | 
        是否通过 | 
        通过 | 
    
    
        | 代码语言 | 
        C++ | 
        运行时间 | 
        0.083 s  | 
    
    
        | 提交时间 | 
        2023-11-13 16:00:12 | 
        内存使用 | 
        1.15 MiB  | 
        
    
    
    
    		显示代码纯文本
		
		#include<bits/stdc++.h>
using namespace std;
map<long long int,long long int> maps;
int n,a[50];
long long key,ans=0,tot=0,sum=0;
void search1(int l,int r)
{
    if(l<=r)
        for(int j=0;j<=1;j++)
       {
         ans+=a[l]*j;
         if(l==r) 
         {
            maps[ans]++;
         }
         else search1(l+1,r);
         ans-=a[l]*j;
    }
}
void search2(int l,int r)
{
    if(l<=r)
        for(int j=0;j<=1;j++)
       {
         tot+=a[l]*j;
         if(l==r) 
         {
            if(maps[key-tot]>0) sum+=maps[key-tot];
         }
         else search2(l+1,r);
         tot-=a[l]*j;
    }
}
int main()
{
    freopen("password1.in","r",stdin);
    freopen("password1.out","w",stdout);
    cin>>n>>key;
    for(int i=1;i<=n;i++) cin>>a[i];
    search1(1,n/2);
    search2(n/2+1,n);
    cout<<sum<<endl;
    return 0;
}