| 记录编号 | 487788 | 评测结果 | AAWWWWTTTT | 
    
        | 题目名称 | 2902.博士的密码 | 最终得分 | 20 | 
    
        | 用户昵称 |  fall in you | 是否通过 | 未通过 | 
    
        | 代码语言 | C++ | 运行时间 | 4.764 s | 
    
        | 提交时间 | 2018-02-12 09:21:50 | 内存使用 | 0.25 MiB | 
    
    
    
    		显示代码纯文本
		
		#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#define ll long long
using namespace std;
int n,cnt;
ll key,sum;
ll a[45];
void dfs(ll,int);
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("%lld",&a[i]);
	}
	dfs(1,1);
	dfs(1,0);
	printf("%d",cnt);
	return 0;
}
void dfs(ll x,int y)
{
	if(x > n) return;
	ll tmp = a[x] * y;
	ll m = sum + tmp;
//	if(m > key) return;	
	if(m == key) {cnt++;return;}
	 	sum += tmp;
	 	dfs(x + 1,0);
		dfs(x + 1,1);
		sum -= tmp;
	return;
}