Given a set of n numbers ai sum up to M, and any K ≤ M, whether there is a subset of the

numbers such that they sum up to (hit)??

**can any one plz explain this code???
and what r the changes required to print those subset???**

```
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
int m[30000],a[21];
int main()
{
int t,N,M,i,j;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&N,&M);
for (i=0;i<N;i++)
scanf("%d",&a[i]);
for (i=0;i<=M;i++)
m[i]=0;
m[0]=1;
for(i=0; i<N; i++)
for(j=M; j>=a[i]; j--)
m[j] |= m[j-a[i]];
if (m[M])
printf("Yes\n");
else
printf("No\n");
}
}
```