Suppose u choose ith element from the Kth set,then
dp[K][Sum]=sum(from i=0 to number of elements in the Kth set)
dp[K-1][Sum-(ith element of Kth set)]

On Sun, Oct 23, 2011 at 3:31 PM, cegprakash <cegprak...@gmail.com> wrote:

> hi i recently came across this problem..
>
> there are K sets
> each sets can contain n numbers from 0 to n
> we've to choose exactly one number from each set
> the sum of all the elements that we chose should be equal to P.
> we have to find how many such possibilities are there to choose so..
>
> for example
>
> assume there are 3 sets containing 1,2,3 elements in them
> so the first set contains 0 and 1
> second set contains 0,1 and 2
> third set contains 0,1,2 and 3
>
> assume P=2
>
> in this case there are 5 possibilities
>
> (0,0,2), (0,1,1), (0,2,0), (1,0,1), (1,1,0)
>
> i'm struggling for a DP solution!! help me out
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
*Regards,*
*Piyush Kapoor,*
*2nd year,CSE
IT-BHU*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to