#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;
//1114 DFS做法
int num[21],res,n,sum;
void dfs(int k){
if(sum>=40){
if(sum==40)
res++;
return;
}
for(int i=k;i<=n;i++){
sum+=num[i];
dfs(i+1);
sum-=num[i];
}
}
int main(){
int i;
while(scanf("%d",&n)!=EOF){
for(i=0;i<n;i++) scanf("%d",num+i);
sum=res=0;
dfs(0);
printf("%d\n",res);
}
return 0;
}
/**************************************************************
Problem: 1114
User: cust123
Language: C++
Result: Accepted
Time:10 ms
Memory:1520 kb
****************************************************************/
题目1114:神奇的口袋
最新推荐文章于 2022-02-27 19:24:57 发布