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

Автор niklasb, 10 лет назад, По-английски

Can somebody describe their solution to http://codeforces.net/gym/100519/problem/I ? Somehow I can't shake the feeling that it's enough to always multiply with 2, but I cannot substantiate my intuition to turn this into an algorithm.

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

»
10 лет назад, # |
Rev. 2   Проголосовать: нравится +10 Проголосовать: не нравится

spoiler

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

    The first one is more along the lines of what I was thinking :) The second idea is magical.

»
10 лет назад, # |
Rev. 5   Проголосовать: нравится +26 Проголосовать: не нравится

It became one of my favourite problems few days ago :)! Indeed, we will use just multiplying by 2. Consider fraction . If we have a fraction f, we multiply it by 2 and then receive information ">" we know that and if we receive "<", we know that . Inductively if we receive informations "<<>><><" and we change each "<" to "1" and ">" to "0" (unless p! = 2 we can't receive "=") we got a prefix of binary representation of f (following "0."), so "<<>><><" changes to "0011010" and we know that . Using 40 questions we can get approximation of with error at most 2 - 40, but if and are potential starting fractions we know that , so this precision is sufficient to uniquely determine starting fraction :)!

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

A wise man.^_^