题目链接:http://bailian.openjudge.cn/practice/4004
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
int NUM = 0;
int SUM = 0;
int a[100];
int t;
void sum(int *a,int m,int n)
{
if(m <= 0 || n <= 0)
return;
int i;
for(i = n - 1;i >= 0;i--)
{
SUM += a[i];
if(SUM == t)
NUM++;
else
if(m > 1)
{
sum(a,m-1,i);
}
SUM -= a[i];
}
}
void main()
{
int i,n;
scanf("%d %d",&n,&t);
NUM = 0;
for(i = 0;i < n;i++)
scanf("%d",&a[i]);
sum(a,n,n);
printf("%d\n",NUM);
}