Most likely overflow, 32bit integers will overflow in the large set. Carlos Guía
On Sun, Sep 13, 2009 at 11:56 PM, Seedrick <[email protected]>wrote: > > hi!! > > i used the exaclty same logic.... > and got the small input correct but the large one wrong... > > What could be the problem with this logic? I have tried all sorts of > possible cases but could not figure this out. > > On Sep 13, 4:50 pm, Ketan Joshi <[email protected]> wrote: > > Hi, > > I used the below logic to solve this: > > > > 1) find number of unique chars in the input number. This becomes the base > in > > which it will have lowest value. > > 2) assign '1' to first char > > 3) assign '0' to second unique char that appears in the input num > > 4) assign 2..base-1 to each unique char that appears in the input in the > > increasing order > > -- So cats becomes 1023 and zig becomes 102 > > 5) result = 0; > > for (i=0;i++;i<length of num){ > > result = result * base + number representing char[i]} > > > > output result. > > > > This logic worked fine for small input. But I got "incorrect" response > for > > large input. > > Can someone tell me if this logic is flawed in any sense? > > > > Regards, > > KeJo > > > > -- > > Blog:http://beingkejo.wordpress.com > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
