Untitled
raw download clone
TEXT
views 16
,
size 447 b
#include <stdio.h>
int tmp[30];
int n;
int function(int a,int sum)
{
    if (sum == 0)
        return 1;
    else if(sum < 0)
        return 0;
    else if (a>n-1)
        return 0;
    else
    {
        return function(a+1,sum)+function(a+1,sum-tmp[a]);
    }
}
int main()
{
    int k;
    scanf("%d%d", &n, &k);
    for(int i=0; i<n; i++)
        scanf("%d", &tmp[i]);
    printf("%d\n",function(0,k));

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