@sunny if we calculate (n-r+1)*(n-r+2).....*n first and then divide this
value by r!..
then this method will fail with little large value of n..because first value
will increase vry fast and will go out of limit..








-----------------------------------------
PRAMENDRA RATHI
NIT ALLAHABAD




On Tue, Jun 21, 2011 at 2:52 PM, sunny agrawal <sunny816.i...@gmail.com>wrote:

> DP is good when we need to use intermediate values too..
> here we only need to compute nCr as a final result
> so we cannot use DP here
>
> the Logic Vandana used will be helpful here.
>
> as nCr = n! / r! * n-r!
> without loss of generality we can assume that r < n-r else we can just
> replace r = n-r
>
>  then we need to compute is
> (n-r+1)*(n-r+2)*.........*(n) / 1.2.3.....r
> that can be computed in O(r)
>
>
>
> On Tue, Jun 21, 2011 at 2:04 PM, kartik sachan <kartik.sac...@gmail.com>wrote:
>
>> but for big numbers this method is very expensive................and hope
>> give TLE in 1 sec question where n=1000
>>
>> --
>> 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.
>>
>
>
>
> --
> Sunny Aggrawal
> B-Tech IV year,CSI
> Indian Institute Of Technology,Roorkee
>
>  --
> 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.
>

-- 
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