weily's blog

By weily, history, 8 hours ago, In English
unordered_map<uint64_t, uint64_t> ump;
uint64_t solve(uint64_t n) {
  if (ump.count(n))
    return ump[n];
  uint64_t p = cube(n - 1);
  uint64_t c = p * p * p;
  uint64_t res = solve(c) + solve(n - c) + (n - c);
  ump[n] = res;
  return res;
}

I'm curious about the time complexity of this recursive function.

Here, the function cube is used to calculate the cube root (not the cube). You can assume that it's $$$O(1)$$$ or $$$O(\log n)$$$.

I believe it is $$$\Omega(\sqrt[3]{n})$$$, but I'd like to know a more precise result and analysis.

You can consider that I've preprocessed $$$[0,m]\cap\mathbb{Z}$$$ as a base case for the recursion (which doesn't seem to offer significant optimization).

Can anyone help me?

English is not my native language; please excuse typing errors.

Full text and comments »

  • Vote: I like it
  • +16
  • Vote: I do not like it

By weily, history, 6 weeks ago, In English

In last night's contest, I didn't come up with the correct solution to problem C. I used many large integers, instead of the least common multiple. But it really worked!

264483249

Can anyone hack it?

English is not my native language; please excuse typing errors.

Full text and comments »

  • Vote: I like it
  • +18
  • Vote: I do not like it