I have one query.

My friend made this solution wherein he found all the masks whose sum was (total/k) and pushed them in a vector.

After that he did this method of checking.

bool flag = false;

for(int i=0; i<test.size(); i++)

{

int cur = test*;

int cnt = 1;

for(int j=0; j<test.size(); j++)

{

if((cur & test[j]) == 0)

{

cur |= test[j];

cnt++;

}

}

```
if(cur == ((1<<n) - 1) && cnt == k)
{
flag = true;
break;
}
}
```

Link: http://www.codechef.com/viewsolution/5513412

Can anyone explain me how does this method covers all the subsets of choosing ‘k’ masks?

I know that a recursive method of finding ‘k’ masks will surely give the correct answer but how does this method do that?

Any help is appreciated.