can any one prove that Decimal number 3 when represented in binary is happy no? On Sat, Sep 12, 2009 at 3:11 PM, Mahendra Kariya <[email protected]>wrote:
> @Antoine: can u tell me ur user name on codejam. I would like to see your > code. > Regards, > Mahendra Kariya > http://www.mahendrakariya.blogspot.com > > > On Sat, Sep 12, 2009 at 3:00 PM, Nzeyimana Antoine > <[email protected]>wrote: > >> >> You are right, you have to stop the loop at value when you already >> have that one in chain(in order to avoid useless repetitons) or just >> stop at a value equal to one(note that 1 has the same value in all >> bases: 2 ... 9) . Then you have to check if a given >> number(increamentally from 2 to max_int) has a happy chains in three >> bases provided . This solved my large input in around 2.5 minutes >> using Java on a 2.2GHz dual CPU, core2duo laptop, but I hope it should >> be much less with other languages like C . >> This problem was relatively easy for me to understand and solve >> because I did a similar one in TopCoder(@least building chain of >> digits square sum in base 10 ), but I didn't undertand the logic of 1C >> ; so my question is ' Is there any big influence from previous >> exercises/contests or experiences to solve quickly these problems ?'. >> >> On 9/12/09, MntlChaos <[email protected]> wrote: >> > >> > Why would you do that? It's happy if it ever reaches 1. If it gets >> > into a different loop, it's unhappy. However, you are correct that 8 >> > is not happy in base 10: 8 => 64 => 52 => 29 => 85 => 89 => 145 => 42 >> > => 20 => 4 => 16 => 37 => 58 => 89, at which point we have a cycle (89 >> > appeared twice). >> > >> > But 7 IS happy in base 10: 7 => 49 => 97 => 130 => 10 => 1 >> > >> > On Sep 12, 1:18 am, Mahendra Kariya <[email protected]> wrote: >> >> I guess in the first ques of Round 1A, we have to check only until the >> sum >> >> of squares of digits is not a single digit integer. Say, for sum >> number, >> >> if >> >> we get the sum of square of digits 8, we stop there and declare it to >> be >> >> unhappy without doing 8*8 = 64 . >> >> >> >> Regards, >> >> Mahendra Kariyahttp://www.mahendrakariya.blogspot.com >> > > >> > >> >> -- >> Sent from my mobile device >> >> >> > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
