Untitled
raw download clone
C
views 29
,
size 365 b
#include<stdio.h>

int n;
long k,a[21];

long NUM(int id,long sum)
{
     if(sum==k)return 1;
     if(id>=n||sum>k)return 0;
     return NUM(id+1,sum+a[id])+NUM(id+1,sum);
}

int main(void)
{
     scanf("%d%ld",&n,&k);

     for(int i=0;i<n;i++)
     {
          scanf("%ld",&a[i]);
     }
     printf("%ld\n",NUM(0,0));

     return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.