@Ishan: Here is the algorithm:
If L <= C, then
cup1 = L
cup2 = cup3 = cup4 = cup5 = cup6 = overflow = 0
else if L < 3*C, then
cup1 = C
cup2 = cup3 = (L-C)/2
cup4 = cup5 = cup6 = overflow = 0
else if L < 5*C, then
cup1 = cup2 = cup3 = C
cup4 = cup6 = (L-3*C)/4
cup5 = (L-3*C)/2
overflow = 0
else if L < 7*C, then
cup1 = cup2 = cup3 = cup5 = C
cup4 = cup6 = (L-3*C)/4
overflow = (L-5*C)/2
else if L >= 7*C, then
cup1 = cup2 = cup3 = cup4 = cup5 = cup6 = C
overflow = L-6*C
And so on.
Dave
On Sep 10, 9:40 am, Ishan Aggarwal <[email protected]>
wrote:
> 1.)
>
> there is a pyramid with 1 cup at level , 2 at level 2 , 3 at level 3 and so
> on..
> It looks something like this
> 1
> 2 3
> 4 5 6
> every cup has capacity C. you pour L liters of water from top . when cup 1
> gets filled , it overflows to cup 2,3 equally, and when they get filled ,
> Cup 4 and 6 get water only from 2 and 3 resp but 5 gets water from both the
> cups and so on.
> Now given C and M .Find the amount of water in ith cup.
>
> --
> Kind Regards
> Ishan Aggarwal
> [image: Aricent Group]
> Presidency Tower-A, M.G.Road,Sector-14
> Gurgaon,Haryana.122015 INDIA
> Phone : +91-9654602663
> [email protected] <[email protected]>
--
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.