#include<stdio.h>
int subsetSum(int n, int selected, int k, int players, int sum, int a[])
{
if(sum==0 && selected==k) return 1;
if(n>players || sum<0) return 0;
return subsetSum(n+1,selected,k,players,sum,a) + subsetSum(n+1,selected+1,k,players,sum-a[n-1],a) ; // either select note or don't
}
int main()
{
int i,j,T,K,Sum,a[11];
while(T--)
{
Sum = 0;
for(i
=0; i
<11; i
++) scanf("%d",&a
[i
]); // Sort i.e find K maximum numbers
for(i=0; i<K; i++)
for(j=1; j<11-i; j++)
if(a[j-1] > a[j])
{
int temp = a[j-1];
a[j-1] = a[j];
a[j] = temp;
}
for(i=0; i<K; i++) Sum += a[11-1-i];
printf("%d\n",subsetSum
(1, 0, K
, 11, Sum
, a
) ); }
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KIAppbnQgc3Vic2V0U3VtKGludCBuLCBpbnQgc2VsZWN0ZWQsIGludCBrLCBpbnQgcGxheWVycywgaW50IHN1bSwgaW50IGFbXSkKewogICAgaWYoc3VtPT0wICYmIHNlbGVjdGVkPT1rKSAgcmV0dXJuIDE7CiAgICBpZihuPnBsYXllcnMgfHwgc3VtPDApICByZXR1cm4gMDsKICAgIHJldHVybiAgc3Vic2V0U3VtKG4rMSxzZWxlY3RlZCxrLHBsYXllcnMsc3VtLGEpICsgc3Vic2V0U3VtKG4rMSxzZWxlY3RlZCsxLGsscGxheWVycyxzdW0tYVtuLTFdLGEpIDsgLy8gZWl0aGVyIHNlbGVjdCBub3RlIG9yIGRvbid0Cn0KIAppbnQgbWFpbigpCnsKICAgIGludCBpLGosVCxLLFN1bSxhWzExXTsKICAgIHNjYW5mKCIlZCIsJlQpOwogICAgd2hpbGUoVC0tKQogICAgewogICAgICAgIFN1bSA9IDA7CiAgICAgICAgZm9yKGk9MDsgaTwxMTsgaSsrKSAgc2NhbmYoIiVkIiwmYVtpXSk7CiAgICAgICAgc2NhbmYoIiVkIiwmSyk7CiAgICAgICAgLy8gU29ydCBpLmUgZmluZCBLIG1heGltdW0gbnVtYmVycwogICAgICAgIGZvcihpPTA7IGk8SzsgaSsrKQogICAgICAgICAgICBmb3Ioaj0xOyBqPDExLWk7IGorKykKICAgICAgICAgICAgICAgIGlmKGFbai0xXSA+IGFbal0pCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgaW50IHRlbXAgPSBhW2otMV07CiAgICAgICAgICAgICAgICAgICAgYVtqLTFdID0gYVtqXTsKICAgICAgICAgICAgICAgICAgICBhW2pdID0gdGVtcDsKICAgICAgICAgICAgICAgIH0KICAgICAgICBmb3IoaT0wOyBpPEs7IGkrKykgU3VtICs9IGFbMTEtMS1pXTsKICAgICAgICBwcmludGYoIiVkXG4iLHN1YnNldFN1bSgxLCAwLCBLLCAxMSwgU3VtLCBhKSApOwogICAgfQogIHJldHVybiAwOwp9IA==