you can calculate nCr using a dynamic programming type algo as nCr = n-1Cr +
n-1Cr-1.
calculate for largest possible n once .. and once thats done, getting this
value would be O(1). Calculating factorial of 500 looks scary

On 23 May 2010 13:49, Mikhail Dektyarev <[email protected]>wrote:

> As I know, dict uses trees, not hashes.
> And to find the right size is not difficult. 501x501 will be enough,
> filling with 0 by default.
>
>
> On Sun, May 23, 2010 at 12:17 PM, Atanas Banov <[email protected]> wrote:
>
>> errr, no. hash lookup is O(1), not log... you are thinking balanced trees
>> or some such.
>> also while 2D array will be a bit faster, you will have to deal with
>> proper sizing and filling default value.
>>
>>
>> On Sat, May 22, 2010 at 8:18 PM, Terence <[email protected]> wrote:
>>
>>>  Another point is to use array (2-D list) instead of dict to implement
>>> cache. this will reduce the time complexity of cache lookup operation from
>>> O(logN) to O(1)
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "google-codejam" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<google-code%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-code?hl=en.
>>
>
>
>
> --
> Best regards, Дектярев Михаил
>
>  --
> You received this message because you are subscribed to the Google Groups
> "google-codejam" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-code%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-code?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-codejam" 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/google-code?hl=en.

Reply via email to