Блог пользователя natsukagami

Автор natsukagami, история, 9 лет назад, По-английски

Hi Codeforces! I was wondering if we could compute a ^ (a + b) ^ (a + 2b) ^ ... ^ (a + kb) in O(1) or such. Thought about it a lot but still I have no solutions :( Do you have any idea? Thank you!

Теги xor
  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

»
9 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится
  1. Simplify the problem to k = 1.
  2. Simplify the problem to a = 1.
  3. Print the first few numbers and look for a pattern.
  • »
    »
    9 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    I didn't quite get the idea. Can you explain it more detailed?

    • »
      »
      »
      9 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Fine, here you go.

      • There are three parameters: a, b and k. Let us first learn how to solve simpler problems by fixing some of the parameters to some small values.

      • With a = 1, k = 1, solve the problem f (b) = a ^ (a + b) ^ (a + 2b) ^ ... ^ (a + kb). Output the first few values and observe.

      • Once you have the solution for the simpler problem, you can return a and k as parameters. For a, it is just g (a, b) = f (b) - f (a - 1). For k, it is perhaps h (a, b, k) = g (a, b) * k or something similar.