@Piyush kapoor: i don't get it.. could u plz explain a lil more?
On Mon, Oct 24, 2011 at 8:19 PM, praveen raj <[email protected]> wrote:
> for 3 set .. set value stored in array a[3] and p is the sum
>
> for( i=0;i<=a[0];i++)
> {
> for(j=0;j<=a[1];j++)
> {
> for(k=a[2];k>=0;k--)
> {
> if((i+j+k)<p) // improve running time
> break;
>
> if((i+j+k)==p)
> cout<<i<<j<<k;
> }
> }
> }
>
> With regards,
>
> Praveen Raj
> DCE-IT 3rd yr
> 9999735993
> [email protected]
>
>
>
>
> On Mon, Oct 24, 2011 at 3:00 AM, Piyush Kapoor <[email protected]>wrote:
>
>> 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 <[email protected]> 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 [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> 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 [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.