find the sum of subset
for(int i=0;i<x;i++)
{
long long int sum=0;
for(int j=0;j<n;j++)
{
if(i&(1<<j))
sum=sum+arr[j];
}
v.push_back(sum);
}
how we are finding the sum of all the subsets using the for loop in this question
http://www.spoj.com/problems/SUBSUMS/
Topic archived. No new replies allowed.