have u ahndled case for numbers which are biggere than long long int
On Sun, Mar 7, 2010 at 2:53 PM, Rohit Saraf <[email protected]>wrote:
> Here is the code if you want... i have not written it...
> it's directly copied from wiki :)
>
> unsigned long long choose(unsigned n, unsigned k) {
> if (k > n)
> return 0;
>
> if (k > n/2)
>
>
> k = n-k; // Take advantage of symmetry
>
> long double accum = 1;
> unsigned i;
> for (i = 1; i <= k; i++)
> accum = accum * (n-k+i) / i;
>
> return accum + 0.5; // avoid rounding error
>
>
> }
>
> call choose(n-1,k-1);
>
>
> -Rohit
>
>
>
> On Sun, Mar 7, 2010 at 2:49 PM, Rohit Saraf
> <[email protected]>wrote:
>
>> The answer is simply : (N-1) Choose (k-1)
>>
>>
>> -Rohit
>>
>>
>>
>> On Sun, Mar 7, 2010 at 2:11 PM, naga vinod kumar <
>> [email protected]> wrote:
>>
>>> How to solve this problem....
>>>
>>> http://www.codechef.com/problems/MARBLES/
>>>
>>>
>>> K.Naga Vinod Kumar
>>>
>>> --
>>> 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]<algogeeks%[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]<algogeeks%[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.