During the week after round 1, I found a much faster way to solve Problem C in Round 1A, "Number Game". It takes O(log(A2) + log(B2)) time, instead of O(min(A2−A1, B2−B1)) like my original solution. So on the large data, my time went from about 92 seconds to 0.07 seconds.
I defined a function f(x) that counts the number of pairs of integers (A,B) such that 1 ≤ A ≤ x and 1 ≤ B ≤ A/phi. (For convenience, you can let x be a real number. f(x) = f( floor(x) ).) Then you can find a formula for f(n) in terms of f( floor(n/phi) ), using properties of phi like phi = 1 + 1/phi. So you can calculate f(n) using O(log(n)) many arithmetical operations. -- 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.
